php 但这些与您的要求或最低稳定性相冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45019784/
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
but these conflict with your requirements or minimum-stability
提问by linux932
I am creating my own slackbot. I decided to use project as a library to help me.
我正在创建自己的 slackbot。我决定将项目用作库来帮助我。
https://github.com/sagebind/slack-client/issues?utf8=%E2%9C%93&q=stability
https://github.com/sagebind/slack-client/issues?utf8=%E2%9C%93&q=stability
Now I need to install it with composer.
现在我需要用 composer 安装它。
So I used the command: composer require coderstephen/slack-client
所以我使用了命令: composer require coderstephen/slack-client
...And I get the error:
......我得到了错误:
Problem 1
- Installation request for coderstephen/slack-client ^0.3.0 -> satisfiable by coderstephen/slack-client[v0.3.0].
- coderstephen/slack-client v0.3.0 requires devristo/phpws dev-master -> satisfiable by devristo/phpws[dev-master] but these conflict with your requirements or minimum-stability.
Ok - So then I decided to change my stability level to "dev" in my composer.lock:
好的 - 然后我决定将我的稳定性级别更改为“dev” composer.lock:
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
"devristo/phpws": 20
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=5.5"
},
"platform-dev": []
Now I'm running out of ideas on what to do. The README says to do this step in composer.json but, no such settings exist:
现在我已经没有想法该怎么办了。自述文件说要在 composer.json 中执行此步骤,但不存在此类设置:
Please note that the current version has unstable dependencies.
In order to install those dependencies, you can set "minimum-stability" in your composer.json, and recommend that you set "prefer-stable":
请注意,当前版本具有不稳定的依赖项。
为了安装这些依赖项,您可以在 composer.json 中设置“minimum-stability”,并建议您设置“prefer-stable”:
My composer.json:
我的作曲家.json:
{
"name": "coderstephen/slack-client",
"keywords": ["slack", "api", "realtime"],
"license": "MIT",
"description": "A better Slack client, with RTM API support",
"authors": [{
"name": "Stephen Coakley",
"email": "[email protected]"
}],
"require": {
"php": ">=5.5",
"devristo/phpws": "dev-master",
"evenement/evenement": "2.0.*",
"guzzlehttp/guzzle": "~6.0",
"react/event-loop": "^0.4.1",
"react/promise": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"fzaninotto/faker": "~1.4",
"apigen/apigen": "^4.1"
},
"autoload": {
"psr-4": {
"Slack\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Slack\Tests\": "tests"
}
}
}
Does anyone know some solutions I could try?
有谁知道我可以尝试的一些解决方案?
回答by Jiri Hrazdil
Add minimum-stabilityand prefer-stableto your composer.json(not composer.lock):
添加minimum-stability和prefer-stable到您的composer.json(不是composer.lock):
{
"name": "coderstephen/slack-client",
"keywords": ["slack", "api", "realtime"],
"license": "MIT",
"description": "A better Slack client, with RTM API support",
"authors": [{
"name": "Stephen Coakley",
"email": "[email protected]"
}],
"require": {
"php": ">=5.5",
"devristo/phpws": "dev-master",
"evenement/evenement": "2.0.*",
"guzzlehttp/guzzle": "~6.0",
"react/event-loop": "^0.4.1",
"react/promise": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"fzaninotto/faker": "~1.4",
"apigen/apigen": "^4.1"
},
"autoload": {
"psr-4": {
"Slack\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Slack\Tests\": "tests"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
回答by Daniel Kratohvil
For others having the same issue, these changes are best done using composer itself instead of manually modifying the composer.json file. Just run the following commands in the console:
对于其他有同样问题的人,最好使用 composer 本身来完成这些更改,而不是手动修改 composer.json 文件。只需在控制台中运行以下命令:
$ composer config minimum-stability dev
$ composer config minimum-stability dev
$ composer config prefer-stable true
$ composer config prefer-stable true
Now you can require and update the package:
现在你可以要求和更新包:
$ composer require --no-update "vendor/package-name:version"
$ composer require --no-update "vendor/package-name:version"
$ composer update
$ composer update
Available options (in order of stability) are dev, alpha, beta, RC, and stable
可用选项(按稳定性顺序)是 dev、alpha、beta、RC 和 stable
回答by Andy
You should never manually edit the composer.lock file - it is an automatically generated file.
你永远不应该手动编辑 composer.lock 文件 - 它是一个自动生成的文件。
It looks like you've shown the composer.json file of the package you're trying to require rather than your own project's composer.json. The prefer-stableand minimum-stabilityproperties should be added to your project root's composer.json file:
看起来您已经显示了您尝试需要的包的 composer.json 文件,而不是您自己项目的 composer.json。在prefer-stable和minimum-stability属性应该被添加到您的项目根的composer.json文件:
{
"name": "xFlare/slack-bot",
"description": "xFlare's Slack bot project",
"authors": [
{
"name": "xFlare"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.5",
"coderstephen/slack-client": "^0.3.0"
}
}
回答by FentomX1
Usually, this issue has nothing to do directly with minimum-stability or prefer-stable option, but the case is just that you already use some library directly or indirectly, that is needed in another library you use but in a higher version.
通常,此问题与最小稳定性或首选稳定选项没有直接关系,但情况只是您已经直接或间接使用了某个库,而您使用的另一个库需要更高版本的库。
My case: I installed Codeception, but had required PHPUnit 4, but Codeception needed at least phpunit 6 - up to 8. Whereas phpunit 6 only supported php7.0 , so I had to explicitly increase my used version of phpunit from 4 to 6, so that the library codeception could work with it.
我的情况:我安装了 Codeception,但需要 PHPUnit 4,但 Codeception 至少需要 phpunit 6 - 最多 8。而 phpunit 6 只支持 php7.0 ,所以我必须明确地将我使用的 phpunit 版本从 4 增加到 6,以便库代码接收可以使用它。
You might ask if it might affect your project which already relies on the lower version of the library, perhaps there could be some breaking change, but I don't know if there could be some workaround for using one version for dependency and another version for own project.
您可能会问它是否会影响您已经依赖于较低版本库的项目,也许可能会有一些重大更改,但我不知道是否有一些解决方法可以使用一个版本作为依赖项而使用另一个版本作为依赖项自己的项目。
Edit: I also had to issue remove composer command for phpunit, otherwise I was not able to increase my phpunit version directly
编辑:我还必须为 phpunit 发出 remove composer 命令,否则我无法直接增加我的 phpunit 版本
回答by Cornelius Fillmore
You should add the minimum-stability in your composer.json not in the composer.lock. The option exists see https://getcomposer.org/doc/04-schema.md#minimum-stability
您应该在 composer.json 中而不是在 composer.lock 中添加最低稳定性。该选项存在,请参阅https://getcomposer.org/doc/04-schema.md#minimum-stability

