如何使用Composer安装没有版本的软件包(仅限主软件)

时间:2014-02-11 06:15:33

标签: composer-php

我是作曲家的新手,我正试图通过作曲家更新

在lib之后安装
https://github.com/neitanod/forceutf8

据我所知,我的composer.json看起来像这样

{
    "config": {
        "vendor-dir": "libs/vendor"
    },
    "require": {
        "raven/raven": "0.7.1",
        "monolog/monolog": "1.7.*",
        "smarty/smarty": "3.1.16",
        "forceutf8/forceutf8": "master"
    }
}

Bt由于某种原因(因为我认为forceutf8没有版本)它的停止有错误,其余所有安装正确,错误我得到

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package forceutf8/forceutf8 could not be found in any version, there may be a typo in the package na
me.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. 

我也尝试了以下版本,但仍然没有运气

{
    "config": {
        "vendor-dir": "libs/vendor"
    },
    "name": "career/skillquest",
    "repositories": [
      {
        "type": "vcs",
        "url": "https://github.com/neitanod/forceutf8"
      }
    ],
    "require": 
      {
        "forceutf8/forceutf8": "dev-master",
        "raven/raven": "0.7.1",
        "monolog/monolog": "1.7.*",
        "smarty/smarty": "3.1.16"
      }
}

问题是它需要

"neitanod/forceutf8": "dev-master"

不是

"forceutf8/forceutf8": "master"

4 个答案:

答案 0 :(得分:20)

首先,您输入的名称错误:forceutf8/forceutf8正确的名称是:neitanod/forceutf8

Composer为每个不像版本号的分支名称添加“dev-”前缀,并为分支名称看起来像版本号的后缀“-dev”添加。

示例:分支“master”称为“dev-master”,分支“feature”称为“dev-feature”。分支“1.0.x”被称为“1.0.x-dev”。

所以这部分是错误的:

"require": {
    "raven/raven": "0.7.1",
    "monolog/monolog": "1.7.*",
    "smarty/smarty": "3.1.16",
    "forceutf8/forceutf8": "master"
}

正确的版本是:

"require": {
    "raven/raven": "0.7.1",
    "monolog/monolog": "1.7.*",
    "smarty/smarty": "3.1.16",
    "neitanod/forceutf8": "dev-master"
}

现在需要没有标记版本的分支并不是最好的事情,因为这些信息非常不稳定 - 任何新的提交都可能会破坏事情,并且要准确指出您想要使用的提交并不容易。为了再次保护您,Composer默认情况下不会加载这些开发分支,而只会加载稳定版本。您必须启用加载开发版本:

"require": {
    "raven/raven": "0.7.1",
    "monolog/monolog": "1.7.*",
    "smarty/smarty": "3.1.16",
    "neitanod/forceutf8": "dev-master@dev"
}

“@dev”标志允许加载所提及版本的开发版本(在这种情况下是一个分支,但“1.0.0@dev”将以相同的方式工作,允许所有(包括开发)版本的1.0 .0,像“1.0.0-alpha”,但也稳定“1.0.0”。

请注意,您还可以通过使用“minimum-stability”允许所有依赖项的开发版本,但不建议这样做,因为它将根据版本要求加载一切的开发版本。在你的情况下,你只会获取monolog的1.7分支的最新开发版本,但这可能足以使曾经稳定的软件进入破坏状态。

答案 1 :(得分:19)

composer.json

{
    "name": "example/example-app",
    "repositories": [
      {
        "type": "vcs",
        "url": "https://github.com/neitanod/forceutf8"
      }
    ],
    "require": 
      {
        "neitanod/forceutf8": "dev-master",
        "raven/raven": "0.7.1",
        "monolog/monolog": "1.7.*",
        "smarty/smarty": "3.1.16"
      }
}

答案 2 :(得分:2)

很简单!您应该在控制台上输入:

composer require blablabla@thepackage dev-master

答案 3 :(得分:1)

您必须在composer.json文件中指定版本名称。 只需找到可以使用Composer安装的任何软件包:https://packagist.org/

在那里搜索包名称,您将找到版本名称。 以下是您想要的软件包的链接:https://packagist.org/packages/neitanod/forceutf8