LoginSignup
16
9

More than 3 years have passed since last update.

Laravel, composer install で PackageManifest でエラーが発生するので解決する

Last updated at Posted at 2020-10-29

少し古いLaravelのバージョンを使っていて composer install をしたところ php artisan package:discover でエラーが発生するようになった。 調べていくとどうやらcomposerで2.0以降のバージョンで vendor/composer/installed.json のフォーマットが変更されていてそれによるエラーが発生しているのがわかった。割と多くの人がつまづきそうなのでメモとして残しておく。

エラーとスタックトレース

php artisan package:discover

production.ERROR: Undefined index: name {"exception":"[object] (ErrorException(code: 0): Undefined index: name at /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php:131)
[stacktrace]
#0 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(131): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined index...', '/var/www/php/ve...', 131, Array)
#1 /var/www/php/vendor/laravel/framework/src/Illuminate/Support/Collection.php(685): Illuminate\\Foundation\\PackageManifest->Illuminate\\Foundation\\{closure}(Array, 'packages')
#2 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(132): Illuminate\\Support\\Collection->mapWithKeys(Object(Closure))
#3 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(106): Illuminate\\Foundation\\PackageManifest->build()
#4 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): Illuminate\\Foundation\\PackageManifest->getManifest()
#5 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): Illuminate\\Foundation\\PackageManifest->config('aliases')
#6 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): Illuminate\\Foundation\\PackageManifest->aliases()
#7 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(219): Illuminate\\Foundation\\Bootstrap\\RegisterFacades->bootstrap(Object(Illuminate\\Foundation\\Application))
#8 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#9 /var/www/php/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#10 /var/www/php/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#11 {main}
"} 

原因

  • composerをlatestでインストールする指定にしていた
  • 最近になってlatestが1系から2.0.0に変更された
  • composer 2.0.0からinstalled.jsonのフォーマットが変わった
  • Laravelで対応するIsuueが出ていてリリースされているがバージョンが古かったためエラーが発生した

対応Isuue

[5.8] Backport support for Composer 2.x #32328
[6.x] Add support for the new composer installed.json format #32310

修正済みのLaravelのバージョン

解決方法

上記のバージョン以降にアップデートすることでエラーは解決します。または composer 1.x 系を利用してください。

16
9
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
16
9