[记一次]composer install --ignore-platform-reqs解决版本冲突
安装horizon的时候提示错误Installation failed, reverting ./composer.json and ./composer.lock to their original content.
然后我重新在homestead的环境上走了下面的操作
- 删除了
composer.lock
- 执行了2个命令:
composer clearcache
和composer update
然后访问larabbs.test
提示这个错误Fatal error: Composer detected issues in your platform:....
(大致的意思是说我的得使用php8.0的版本)
我对此和疑惑,但是这个报错我之前也遇到过,我就在composer.json
的 config 下添加了这个配置
继续访问依旧无效
我继续百度之后发现
删除vender目录,然后运行composer install --ignore-platform-reqs
就可以正常访问了。
composer install –ignore-platform-reqs 就相当于设置了忽略版本匹配
值得一提的是我本地的php版本是7.4,但是homestead中php的版本是8.0,
我在本地执行命令composer require "laravel/horizon:~5.6"
会提示错误信息
我再进入homestead环境中执行同样的命令后就提示这个信息
然后我就重新执行了一下composer require laravel/ui
,我就重新加载了一下依赖,继续在homestead里面加载horizon的时候就ok了,简直了。
我感觉我之后加载依赖都要冲homestead里面加载不能本地加载
虽然解决了我的问题,但是我依旧有些疑惑第一个错误是怎么导致的,奇怪的很
遇到上面这种问题,我刚刚又碰到了。
环境是windows10
需要通过参数来设置
--ignore-platform-reqs
忽略版本,比如命令composer require --ignore-platform-reqs "predis/predis:~1.1"
。至于是什么原因导致的,我暂时还不知道