php7の時の環境をcomposer.lock に保存して、
phpを8にバージョンアップした。
その後、composer install でエラーになった。ちなみに、composer updateでもエラーになる。
上記の解決方法
$ 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
- Root composer.json requires php ^7.2.5 but your php version (8.2.9) does not satisfy that requirement.
Problem 2
- facade/ignition is locked to version 2.4.2 and an update of this package was not requested.
- facade/ignition 2.4.2 requires php ^7.2.5 -> your php version (8.2.9) does not satisfy that requirement.
Problem 3
- facade/ignition-contracts is locked to version 1.0.1 and an update of this package was not requested.
- facade/ignition-contracts 1.0.1 requires php ^7.1 -> your php version (8.2.9) does not satisfy that requirement.
Problem 4
- phpspec/prophecy is locked to version v1.15.0 and an update of this package was not requested.
- phpspec/prophecy v1.15.0 requires php ^7.2 || ~8.0, <8.2 -> your php version (8.2.9) does not satisfy that requirement.
Problem 5
- facade/ignition-contracts 1.0.1 requires php ^7.1 -> your php version (8.2.9) does not satisfy that requirement.
- nunomaduro/collision v4.3.0 requires facade/ignition-contracts ^1.0 -> satisfiable by facade/ignition-contracts[1.0.1].
- nunomaduro/collision is locked to version v4.3.0 and an update of this package was not requested.
$ composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.Problem 1
- Root composer.json requires php ^7.2.5 but your php version (8.2.9) does not satisfy that requirement.
composer.lock に書いてあるバージョンの依存関係を無視しろって命令するパターン。
$ composer install --ignore-platform-reqs
composer.json を書き換えるパターン。
PHPのバージョンが新しいのにComposerでエラーが出る理由とその対応方法 | Dev Nest
composer install --ignore-platform-reqs でインストールしたところ、
インストールは出来たが、再度エラーが出た
In Collection.php line 11:
During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess
::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/xxxxxxxxxxxxxx/vendor/laravel/
framework/src/Illuminate/Support/Collection.php:1349
Stack trace:
#0 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /var/www/xxxxxxxxxxxxxx/vendor/composer/ClassLoader.php(576): include('...')
#2 /var/www/xxxxxxxxxxxxxx/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}()
#3 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Support/helpers.php(110): Composer\Autoload\ClassLoader->loadClass()
#4 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(130): collect()
#5 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(106): Illuminate\Foundation\PackageManifest->build()
#6 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): Illuminate\Foundation\PackageManifest->getManifest()
#7 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config()
#8 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()
#9 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap()
#10 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith()
#11 /var/www/xxxxxxxxxxxxxx/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#12 /var/www/xxxxxxxxxxxxxx/artisan(35): Illuminate\Foundation\Console\Kernel->handle()
#13 {main}
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
直接書き換えるしかなさそう
以下の方法が正解っぽい
"php": "^7.2.5", から "php": "^7.2.5||^8.0", に変えて保存
$ composer update
laravelもバージョンアップ
composer.json書き換え
"php": "^8.0",
"guzzlehttp/guzzle": "^7.0.1",
"facade/ignition": "^2.3.6",
"laravel/framework": "^8.0",
"laravel/ui": "^3.0",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0",
Laravelフレームワークをバージョンアップする方法まとめ! | コードライク
composer update
上は間違い。
以下の方法が正解。
Laravel のバージョンアップ、アップグレードの方法 - blog