laravel 如何解决“无法将您的要求解析为一组可安装的软件包”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29318709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I resolve "Your requirements could not be resolved to an installable set of packages" error?
提问by cyber8200
When I run composer update
I receive some wired output.
当我跑步时,composer update
我会收到一些有线输出。
Here is my composer.json look like.
这是我的 composer.json 的样子。
{
"name": "laravel/laravel",
"description": "The Laravel Framework.", "keywords": ["framework", "laravel"],
"license": "MIT",
"repositories": [{
"type": "vcs",
"url": "https://github.com/Zizaco/ardent.git"
}],
"require-dev": {
"phpunit/phpunit": "4.3.*"
},
"require": {
"laravel/framework": "4.2.*",
"laravelbook/ardent": "dev-master as 2.4.0",
"zizaco/entrust": "dev-master",
"sebklaus/profiler": "dev-master",
"doctrine/dbal": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations", "app/database/seeds", "app/tests",
"app/libraries"
]
},
"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 artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
How do I fix that ?
我该如何解决?
采纳答案by Sven
Your software dependencies have an incompatible version conflict.
您的软件依赖项存在不兼容的版本冲突。
At the same time you want to install any Laravel 4.2.x version, and "zizaco/entrust" from its master branch. And that master branch requires at least Laravel 5.0 (roughly speaking).
同时你想安装任何 Laravel 4.2.x 版本,并从它的 master 分支安装“zizaco/entrust”。而那个 master 分支至少需要 Laravel 5.0(粗略地说)。
The problem comes from the dependency on branches. It's likely that the package zizaco/entrust once was using Laravel 4.2 in its master branch, and that you were able to install your dependencies at that day. But the very moment this branch gets updated with an incompatible version requirement, you will never ever be able to run composer update
and get updated dependencies.
问题来自对分支的依赖。很可能 zizaco/entrust 包曾经在其 master 分支中使用 Laravel 4.2,并且您可以在那天安装您的依赖项。但是,当这个分支因版本要求不兼容而更新时,您将永远无法运行composer update
并获得更新的依赖项。
Always use tagged versions! Ideally you use a relaxed version requirement that allows for compatible updates. This should be expressed as a tilde-two-number version requirement: ~1.2
would install a version 1.2.0 and up (like 1.2.99 or 1.2.100), and also 1.3 and up. If you need a certain patch release: Caret-three-number version ^1.2.10
will install 1.2.10 or up, also 1.3 and up.
始终使用标记版本!理想情况下,您使用允许兼容更新的宽松版本要求。这应该表示为波浪号两个数字版本要求:~1.2
将安装 1.2.0 及更高版本(如 1.2.99 或 1.2.100),以及 1.3 及更高版本。如果您需要某个补丁版本: Caret-three-number 版本^1.2.10
将安装 1.2.10 或更高版本,也将安装 1.3 及更高版本。
Using this version requirement instead of dev-master
will allow you to use released versions instead of the unstable state in the master branch, and allows you to address the most recent version that still works with Laravel 4.2. I guess that would be zizaco/entrust version 1.3.0, but version 1.2 would also qualify. Go with "zizaco/entrust": "~1.2"
.
使用此版本要求而不是dev-master
允许您使用已发布版本而不是 master 分支中的不稳定状态,并允许您解决仍可与 Laravel 4.2 一起使用的最新版本。我想这将是 zizaco/entrust 1.3.0 版,但 1.2 版也符合条件。与"zizaco/entrust": "~1.2"
.
回答by Gufran Hasan
Run this command:
运行此命令:
composer install --ignore-platform-reqs
composer install --ignore-platform-reqs
or
或者
composer update --ignore-platform-reqs
作曲家更新 --ignore-platform-reqs
回答by Ankit
I am facing the same issue. I am using 'Lumen' microservice framework. I recently resolved the same issue by installing two packages:-
我面临同样的问题。我正在使用“Lumen”微服务框架。我最近通过安装两个软件包解决了同样的问题:-
- sudo apt-get install php7.0-mbstring,
- sudo apt-get install php7.0-xmlor sudo apt-get install php-xml
- 须藤 apt-get 安装php7.0-mbstring,
- sudo apt-get install php7.0-xml或 sudo apt-get install php-xml
After installing this, you need to execute this command:- composer update
安装后,您需要执行此命令:- composer update
Hope, it will resolve the issue. I work on my system.
希望,它会解决这个问题。我在我的系统上工作。
回答by Estus Flask
Were those dev-master
s added automatically? Avoid them as unnecessary version constraints, for 'any suitable version' use "*"
, or "@dev"
if you don't mind dev packages. My guess is that Entrust is the potential troublemaker.
那些dev-master
是自动添加的吗?避免它们作为不必要的版本约束,用于“任何合适的版本”使用"*"
,或者"@dev"
如果您不介意开发包。我的猜测是 Entrust 是潜在的麻烦制造者。
Also, "minimum-stability": "stable"
imposes additional constraints, and
此外,"minimum-stability": "stable"
强加了额外的约束,和
"minimum-stability": "dev",
"prefer-stable": true
is more conflict-free, consider it a rule of thumb.
更无冲突,将其视为经验法则。
回答by Tahir Yasin
Add "barryvdh/laravel-cors": "^0.7.3"
at the end of require
array inside composer.json
在 composer.json 中"barryvdh/laravel-cors": "^0.7.3"
的require
数组末尾添加
Save composer.json and run composer update
保存 composer.json 并运行 composer update
You are done !
你完成了!
回答by Full Heleno
"config": {
"platform": {
"ext-pcntl": "7.2",
"ext-posix": "7.2"
}
}
回答by BlackPearl
I encountered this problem in Laravel 5.8, what I did was to do composer require
for each library and all where installed correctly.
我在 Laravel 5.8 中遇到了这个问题,我所做的是composer require
对每个库和所有正确安装的地方做。
Like so:
像这样:
instead of adding it to the composer.json file or specifying a version:
而不是将其添加到 composer.json 文件或指定版本:
composer require msurguy/honeypot: dev-master
I instead did without specifying any version:
相反,我没有指定任何版本:
composer require msurguy/honeypot
I hope it helps, thanks
我希望它有帮助,谢谢
回答by nicolasDevDes
I solved the same issue setting 'laravel/framework'
dependency version from "^8.0"
to "^7.0"
.
我解决了'laravel/framework'
从"^8.0"
to设置依赖版本的相同问题"^7.0"
。
After that running composer update --ignore-platform-reqs
simply worked
在那之后运行composer update --ignore-platform-reqs
简单地工作
回答by Simon Njenga
CAUSE:
原因:
The error is happening because your project folder is owned by the root user.
发生错误是因为您的项目文件夹归 root 用户所有。
SOLUTION
解决方案
Change ownership to the currently signed in user and not the root user. If you only have root as the sole user, create another user with root privileges.
将所有权更改为当前登录的用户而不是 root 用户。如果您只有 root 作为唯一用户,请创建另一个具有 root 权限的用户。
$ sudo chown -R current_user/my/project/directory/
$ sudo chown -R current_user/my/project/directory/
then
然后
$ composer install
$作曲家安装
回答by Gideao
Just activate the curl in the php.ini file
只需激活 php.ini 文件中的 curl
;extension=php_curl.dll
to
到
extension=php_curl.dll
and then composer install
然后作曲家安装