我正在测试Laravel框架新的5.1版本。
我想安装著名的barryvdh/laravel-ide-helper
软件包。
一个知道问题是:barryvdh/laravel-ide-helper
需要illuminate/filesystem: 5.0.x
,laravel/framework
需要illuminate/filesystem: 5.1.x
。
如何配置我的composer.json
文件?
注意:我的 composer.json 文件中有"minimum-stability": "dev"
和"prefer-stable": true
。
安装时,我收到此错误:
Problem 1
- Conclusion: remove laravel/framework 5.1.x-dev
- barryvdh/laravel-ide-helper 2.0.x-dev requires illuminate/filesystem 5.0.x -> satisfiable by illuminate/filesystem[5.0.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.4].
- barryvdh/laravel-ide-helper v2.0.0 requires illuminate/filesystem 5.0.x -> satisfiable by illuminate/filesystem[5.0.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.4].
- barryvdh/laravel-ide-helper v2.0.1 requires illuminate/filesystem 5.0.x -> satisfiable by illuminate/filesystem[5.0.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.4].
- barryvdh/laravel-ide-helper v2.0.2 requires illuminate/filesystem 5.0.x -> satisfiable by illuminate/filesystem[5.0.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.4].
- barryvdh/laravel-ide-helper v2.0.3 requires illuminate/filesystem 5.0.x -> satisfiable by illuminate/filesystem[5.0.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.4].
- don't install illuminate/filesystem 5.0.x-dev|don't install laravel/framework 5.1.x-dev
- don't install illuminate/filesystem v5.0.0|don't install laravel/framework 5.1.x-dev
- don't install illuminate/filesystem v5.0.22|don't install laravel/framework 5.1.x-dev
- don't install illuminate/filesystem v5.0.25|don't install laravel/framework 5.1.x-dev
- don't install illuminate/filesystem v5.0.26|don't install laravel/framework 5.1.x-dev
- don't install illuminate/filesystem v5.0.28|don't install laravel/framework 5.1.x-dev
- don't install illuminate/filesystem v5.0.4|don't install laravel/framework 5.1.x-dev
- Installation request for laravel/framework 5.1.* -> satisfiable by laravel/framework[5.1.x-dev].
- Installation request for barryvdh/laravel-ide-helper ^2.0@dev -> satisfiable by barryvdh/laravel-ide-helper[2.0.x-dev, v2.0.0, v2.0.1, v2.0.2, v2.0.3].
我已经尝试了以下所有命令,结果相同...
$ composer require barryvdh/laravel-ide-helper,
$ composer require barryvdh/laravel-ide-helper:@dev --dev
$ composer require barryvdh/laravel-ide-helper --dev --update-with-dependencies
我还尝试composer.json
文件上创建一个别名:
"require": {
"laravel/framework": "5.1.*",
"illuminate/filesystem": "5.1.x-dev as 5.0.28"
},
然后出现此错误:
Problem 1
- Installation request for barryvdh/laravel-ide-helper dev-master -> satisfiable by barryvdh/laravel-ide-helper[dev-master].
- Conclusion: remove laravel/framework 5.1.x-dev
- Conclusion: don't install laravel/framework 5.1.x-dev
- barryvdh/laravel-ide-helper dev-master requires illuminate/filesystem 5.0.x -> satisfiable by illuminate/filesystem[5.0.x-dev, 5.0.28].
- don't install illuminate/filesystem 5.0.x-dev|don't install laravel/framework 5.1.x-dev
- don't install illuminate/filesystem 5.0.28|don't install laravel/framework 5.1.x-dev
- Installation request for laravel/framework 5.1.* -> satisfiable by laravel/framework[5.1.x-dev].
这是我composer.json
文件:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.1.*",
"illuminate/filesystem": "5.1.x-dev as 5.0.28"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"Portal\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r "copy('.env.example', '.env');"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true
}
核心问题源于对5.0.x
过于严格的版本约束。我不知道这是否有充分的理由。
一种选择是将laravel-ide-helper
分叉到您自己的存储库中,将版本约束更改为类似^5.0
(可能还有包名称),并将分叉存储库作为 git 存储库添加到composer.json
文件中。这将使您至少查看它是否按预期工作。
问题是,正如您所指出的,您安装了 Laravel 5.1(顺便说一句,它仍然不稳定,我不建议使用它 atm)并且该软件包需要 5.0.*。
有几种解决方案:
- 在 laravel ide 帮助程序存储库中创建一个问题,要求作者缓解版本约束。请注意,这个库与版本密切相关,这可能就是版本约束如此严格的原因。
- 不要安装不稳定的 5.1 版本,但坚持使用 5.0 并在发布和更新包时使用 5.1。
我已经在我的composer.json
文件中用一个别名解决了:
"require": {
"laravel/framework": "5.1.x-dev as 5.0.28"
},
所以,laravel/framework有"illuminate/filesystem": "5.1.x-dev"
,barryvdh/laravel-ide-helper
认为有"illuminate/filesystem": "5.0.28"
我的第一个方法:
"require": {
"laravel/framework": "5.1.*",
"illuminate/filesystem": "5.1.x-dev as 5.0.28"
},
它不起作用,因为illuminate/filesystem
它被laravel/framework
用作子树,然后我必须为laravel/framework
而不是illuminate/filesystem
设置别名。