如果我创建一个空文件夹并将 composer.json 放在那里:
{
"require": {
"silex/silex": "1.0.*@dev"
}
}
然后运行composer install
- 它工作正常,微框架 silex 和它的所有要求都将安装到供应商文件夹中。行。
现在更复杂的例子,我无法理解为什么它不起作用。我有一个项目(称为“FB”),它依赖于我自己的“某种框架”(称为“light/light4”)。FB 项目的 composer.json:
{
"repositories":[
{
"type":"hg",
"url":"http://bitbucket.org/pqr/light4"
}
],
"require":{
"light/light4":"dev-default"
}
}
如您所见,这取决于我在 bitbucket 上托管的框架 light/light4。然后是 light/light4 composer.json:
{
"name":"light/light4",
"version":"1.0.0",
"require":{
"php":">=5.4.0",
"silex/silex": "1.0.*@dev",
"twig/twig":">=1.8,<2.0-dev",
"monolog/monolog":">=1.0.0",
"symfony/validator":"2.1.*",
"symfony/console":"2.1.*"
},
"autoload":{
"psr-0":{
"Light":"src/"
},
"files":[
"src/functions/body.php", "src/functions/db.php", "src/functions/file.php", "src/functions/misc.php"
]
}
}
light/light4 取决于 silex/silex 和其他一些东西。
由于我从未提及"minimun-stability":"dev"
- 假设默认情况下所有软件包都将安装为稳定版本。除了 light/light4 要求的 Silex/silex 为"silex/silex": "1.0.*@dev"
不幸的是,当我composer -v install
在根项目(FB)上运行时,我收到以下错误:
Loading composer repositories with package information
Reading composer.json of light/light4 (default)
Importing branch default (dev-default)
Installing dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- light/light4 dev-default requires silex/silex 1.0.*@dev -> no matching package found.
- light/light4 dev-default requires silex/silex 1.0.*@dev -> no matching package found.
- Installation request for light/light4 dev-default -> satisfiable by light/light4 dev-default.
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.
silex/silex 1.0.*@dev -> no matching package found
- 为什么???它适用于简单的空项目,但不适用于需求链:(
composer-dev irc 有人建议将"silex/silex": "1.0.*@dev"
FB 项目的一般 composer.json 放入。我试过了——现在它可以工作了:所有软件包都安装在稳定版本中,并且我想要的开发版本中唯一的 silex/silex。现在我完全糊涂了。
问题仍然存在 - 为什么它在一般 composer.json 中有效而在嵌套(必需)项目 light/light4 中无效?我要了解问题的根源,还是只是作曲家的错误?