问题
I updated the composer with this command:
composer self-update
It was updated to version 2.0.4. Then when I tried to launch my Laravel project using:
php artisan serve
I got this error:
In PackageManifest.php line 131:
Undefined index: name
I tried getting back to the old version of the composer with this:
composer self-update --rollback
The composer was downgraded to version 1.9.3, but it didn't help with the error. Then I used this command to update the composer again:
composer self-update --stable
And still got the same error.
This is the line 131 of the PackageManifest.php file:
return [$this->format($package['name']) => $package['extra']['laravel'] ?? []];
回答1:
First, you should check again version after using composer self-update
. Then, you try composer update
. Finally, you run php artisan serve
.
回答2:
The issue is one of the Laravel 6 default vendor packages has a small bug.
The solution to fix this is the following:
rm -rf composer.lock
rm -rf vendor
composer install
This will update the composer packages to the latest versions for your current version of laravel and this should resolve the issue.
回答3:
add code in Illuminate\Foundation\PackageManifest.php about to line 129:
...
$ignoreAll = in_array('*', $ignore = $this->packagesToIgnore());
// ------------------:::::::::FIX::::::::::------------
if (isset($packages['packages'])){
$packages = $packages['packages'];
}
// ---------------------------ENDFIX-------------------
$this->write(collect($packages)->mapWithKeys(function ($package) {
...
来源:https://stackoverflow.com/questions/64620849/laravel-packagemanifest-php-line-131-undefined-index-name