composer

执行 composer update 命令的时候报 Your requirements could not be resolved to an installable set of packages. 错误
Your requirements could not be resolved to an installable set of packages.



以上原因:不匹配composer.json要求的版本。



解决方案:



composer可以设置忽略版本匹配,



composer install –ignore-platform-reqs



composer update –ignore-platform-reqs
再次执行composer命令可以正常安装包了



Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.



Problem 1
- The requested package xxx is satisfiable by xxx but these conflict with your requirements or minimum-stability.



原因,composer.lock 里有两个版本的包,删除一个就可以了




Your requirements could not be resolved to an installable set of packages.



Problem 1
- The requested package xxx (locked at 1.5.48, required as dev-xxx as dev-master) is satisfiable by xxx[1.5.48] but these conflict with your requirements or minimum-stability.



执行以下命令:



composer require sonata-project/doctrine-orm-admin-bundle “2.3.*”



报错:



PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 32 bytes)



解决:



php -r “echo ini_get(‘memory_limit’).PHP_EOL;” # 查看memory大小



COMPOSER_MEMORY_LIMIT=-1 composer require sonata-project/doctrine-orm-admin-bundle # 临时设置memory大小



参看官方说明(打开太慢了):



https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors



问题2



but these conflict with your requirements or minimum-stability.



解决:在composer.json中添加以下



“minimum-stability”: “dev”,



切换composer国内镜像



composer config -g repo.packagist composer https://packagist.phpcomposer.com



我是tp5.1下,用composer安装扩展包,在命令行运行,无任何不反应,不下载也不报错,这时,我们先ctrl+c退出执行的命令,然后在tp5.1根目录下,找到composer.json文件,并用编辑器打开,在最后追加上如下内容:



“repositories”: {
“packagist”: {
“type”: “composer”,
“url”: “https://packagist.phpcomposer.com”
}
}
保存退出,然后在cmd命令行执行运行命令,就ok了。



composer安装扩展包时,可以设置忽略版本匹配,命令如下:



composer install –ignore-platform-reqs
如果不知道扩展包的具体版本,可以写 * ,* 会下载最新的版本



“require”: {
“topthink/think-helper”:”*”
},
或者写 dev-master,dev-master作者也是很懵逼



“require”: {
“topthink/think-helper”:”dev-master”
},
再或者随便填写一个不存在的版本,cmd命令执行的时候,会报错,这时会提示该扩展包有哪些版本号,如作者填写的是 1.0 版本,当然这个版本执行的时候会报错并列出改扩展包都有哪些版本



“require”: {
“topthink/think-helper”:”1.0”
},
然后填写到composer.json文件里,然后在命令行进行执行 composer update,就会进行安装,ok了。



安装报错
错误如下:



Your requirements could not be resolved to an installable set of packages.
Problem 1
- overtrue/http 1.0.1 requires php >=7.0 -> your PHP version (5.6.34) does not satisfy that requirement.
- overtrue/http 1.0.0 requires php >=7.0 -> your PHP version (5.6.34) does not satisfy that requirement.
- overtrue/sendcloud 1.0.0 requires overtrue/http dev-master -> satisfiable by overtrue/http[dev-master] but these conflict with your requirements or minimum-stability.
- overtrue/sendcloud 1.0.1 requires overtrue/http ^1.0 -> satisfiable by overtrue/http[1.0.0, 1.0.1].
- Installation request for overtrue/sendcloud ^1.0 -> satisfiable by overtrue/sendcloud[1.0.0, 1.0.1].



Installation failed, reverting ./composer.json to its original content.
这是因为php版本不匹配,如下执行命令,进行忽略版本



composer install –ignore-platform-reqs
或者
composer update –ignore-platform-reqs
再次执行composer命令可以正常安装包了。



只要在你项目根目录的 composer.json 文件中加入以下内容:



{
“repositories”: [
{
“type”: “vcs”,
“url”: “https://github.com/you/monolog”
}
],
“require”: {
“symfony/monolog-bundle”: “2.0”,
“monolog/monolog”: “dev-bugfix as 1.0.x-dev”
}
}
它将会在你的 GitHub 上获取 monolog/monolog 的 dev-bugfix 版本并将其版本别名为 1.0.x-dev。



oading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.



Problem 1



  • The requested package overtrue/laravel-lang 3.0.14 is satisfiable by overtrue/laravel-lang[3.0.14] but these conflict with your requirements or minimum-stability.



以上是报错内容



解决方案:



删掉composer.lock文件中对应的错的地方,或者修改低级别的版本



再次执行composer install



一、composer require guzzlehttp/guzzle报错Your requirements could not be resolved to an installable set of
提示组件不能被安装,搜了下说是版本不兼容。



[xc@iZ19999xdnwm akm]$ composer require guzzlehttp/guzzle
Using version ^6.3 for guzzlehttp/guzzle
./composer.json has been updated
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 minimum-stability could not be found in any version, there may be a typo in the package name.
Problem 2
- overtrue/wechat 3.2.5 requires guzzlehttp/guzzle ~6.2.1 -> satisfiable by guzzlehttp/guzzle[6.2.1, 6.2.2, 6.2.3, 6.2.x-dev] but these conflict with your requirements or minimum-stability.
- overtrue/wechat 3.2.5 requires guzzlehttp/guzzle ~6.2.1 -> satisfiable by guzzlehttp/guzzle[6.2.1, 6.2.2, 6.2.3, 6.2.x-dev] but these conflict with your requirements or minimum-stability.
- overtrue/wechat 3.2.5 requires guzzlehttp/guzzle ~6.2.1 -> satisfiable by guzzlehttp/guzzle[6.2.1, 6.2.2, 6.2.3, 6.2.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for overtrue/wechat (locked at 3.2.5, required as ~3.1) -> satisfiable by overtrue/wechat[3.2.5].



Potential causes:




Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.



Installation failed, reverting ./composer.json to its original content.



解决办法:在composer.json中添加以下
“minimum-stability”: “dev”, //这个遇上require时完全可以用上



[xc@iZ19999xdnwm akm]$ vim composer.json
{
“minimum-stability”: “dev”,//要加在require上一级才能生效,如果require里面已经有了guzzlehttp/guzzle的版本,也要删掉。
“require”: {
“overtrue/wechat”: “~3.1”,
“hanson/vbot”: “^1.0”,
“snowair/phalcon-debugbar”: “^1.1”,
“phpoffice/phpexcel”: “^1.8”,
“symfony/dom-crawler”: “^3.3”,
“khanamiryan/qrcode-detector-decoder”: “^1.0”,
“alchemy/zippy”: “^0.4.8”,
“guzzlehttp/guzzle”: “^6.2@dev”//这一行是安装成功后生成的,可以忽略
}
}



执行命令会先remove旧版本,然后install新版本,这一步过程我没有截图。贴出成功后的输出。



[xc@iZ19999xdnwm akm]$ composer require guzzlehttp/guzzle
Using version ^6.2@dev for guzzlehttp/guzzle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files


Category php