経緯
以下の手順でエラーが発生しました。
$ composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- asm89/stack-cors is locked to version v2.0.1 and an update of this package was not requested.
- asm89/stack-cors v2.0.1 requires php ^7.0 -> your php version (8.1.2) does not satisfy that requirement.
・
・
・
とりあえずメッセージの通りcomposer update
してみる。
$ composer update
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires php ^7.3 but your php version (8.1.2) does not satisfy that requirement.
composer updateもできませんでした。。
どうやらphp7.3が必要なのにphp8を使っていること
が原因のようです!
解決
以下のように、composer.json
にphpバージョン8
を追加してあげます!
これでphp8でコマンド実行してもエラーは出なくなります!
"require": {
"php": "^7.3",
},
↓ //8.0を追加
"require": {
"php": "^7.3|^8.0",
},
再度composer updateからinstallまで実行
$ composer update
・
・
・
Package manifest generated successfully.
77 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
$ composer install
・
・
・
Package manifest generated successfully.
77 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
これで無事成功です!
参考記事