34

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'] ?? []];
5
  • 3
    After using composer self-update to update version of composer, did you tried to run againcomposer update before running php artisan serve? Commented Oct 31, 2020 at 11:00
  • no, should I try it now? Commented Oct 31, 2020 at 11:02
  • Yes, you should do it. Commented Oct 31, 2020 at 11:03
  • First, you should check again version after using composer self-update. Then, you try composer update. Finally, you run php artisan serve Commented Oct 31, 2020 at 11:05
  • 1
    That's what I was missing! It worked! Thank you so much! Commented Oct 31, 2020 at 11:08

6 Answers 6

70

First, you should check again version after using composer self-update. Then, you try composer update. Finally, you run php artisan serve.

Sign up to request clarification or add additional context in comments.

Comments

25

The issue is one of the Laravel 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.

Comments

14

This was actually fixed in Laravel already, so please make sure you update Laravel to at least 6.18.7+ or 7.6.0+ or 8.0+

FYI, if you remove composer local file, it will update all your dependencies, so it's not a good idea.

By running the command composer update laravel/framework should hopefully fix the issue and not cause any other problems. If you can not update Laravel then you better off downgrade to Composer 1 using composer self-update --1.

If you are using illuminate/foundation instead of laravel/framework, then make sure you composer update illuminate/foundation instead.

2 Comments

this helped me : downgrade to Composer 1 using composer self-update --1
Downgrading composer to version 1 (which same version on production server) was the best solution. The whole purpose of having of local environment is to be as similar to production as possible. Thanks!
8

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) {
    ...

5 Comments

Of course. But sometimes we need to ignore rules, becouse the life is more complicated then rules. This is one of these cases. this fix make composer workable to update the saint vendor folder too. You can publish your decision better than this.
then one day you are left scratching your head because you did something stupid and ignored the rules. The solution is already posted here from @advertmanagerpro.com
He offers an ax, and I offer a scalpel, both tools solve the problem, the choice is up to the user
This worked for me, although my edit was done on line 121, not 129
I agree with @Snapey, you should never change code directly inside the vendor folder. As you will very likely loose it as soon as you do a composer update or try to install a new composer package. Plus most people have the vendor folder in the .gitignore file so the vendor folder will never get saved to backup repositories like github or similar. It is bad practice to make changes inside the vendor folder.
5

Option 1:

Open vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php

then search code :

$packages = json_decode($this->files->get($path), true);

insert

$packages = $installed['packages'] ?? $installed;

Option 2 :

run command

composer update

Comments

2

this helped me :

downgrade to Composer 1 using

composer self-update --1 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.