LoginSignup
1
2

More than 1 year has passed since last update.

Your requirements could not be resolved to an installable set of packages. 解決方法

Posted at

経緯

以下の手順でエラーが発生しました。

$ 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.jsonphpバージョン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!

これで無事成功です!

参考記事

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2