我是composer的新手,我正试图通过composer更新安装以下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"
首先,您的名称错误: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的所有(包括dev)版本,如"1.0.0-alpha",但也允许稳定的"1.0.0")
请注意,您也可以通过使用"最低稳定性"来允许所有依赖项的开发版本,但不建议这样做,因为它将根据版本要求加载EVERYTHING的开发版本。在您的情况下,您只需要获取monlog 1.7分支的最新开发版本,但这可能足以使一个曾经稳定的软件进入崩溃状态。
在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"
}
}
很简单!您应该在控制台上键入:
composer require blablabla@thepackage dev-master
您必须在composer.json文件中指定版本名。只需在以下位置找到任何可使用Composer安装的软件包:https://packagist.org/
在那里搜索包名称,你会找到版本名称。这是您想要的包裹的链接:https://packagist.org/packages/neitanod/forceutf8