Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel PackageManifest.php line 131: Undefined index: name

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'] ?? []];
like image 689
Ala Ben Aicha Avatar asked Oct 31 '20 10:10

Ala Ben Aicha


People also ask

Why is my Composer package not working in Laravel?

The issue is one of the Laravel default vendor packages has a small bug. This will update the composer packages to the latest versions for your current version of laravel and this should resolve the issue.

How to stop Laravel framework from updating packages?

If you want to avoid updating packages, go to vendor/composer and remove installed.json I was facing the same issue. I Saw my Laravel framework version is "laravel/framework": "6.0" So just put the cap before the version and it starts working fine. "laravel/framework": "^6.0"

What version of Laravel composer was downgraded to?

Show activity on this post. It was updated to version 2.0.4. Then when I tried to launch my Laravel project using: 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: And still got the same error.

Should --no-scripts be used when creating a package manifest file?

Don't use --no-scripts. This will cause a problem, and will not create the appropiate folders which the file PackageManifest.php and others need. This is so you don't have problems with bugs in the file. vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php $packages = json_decode ($this->files->get ($path), true);


Video Answer


7 Answers

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

like image 150
Thân LƯƠNG Avatar answered Oct 19 '22 05:10

Thân LƯƠNG


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.

like image 28
centralhubb.com Avatar answered Oct 19 '22 06:10

centralhubb.com


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.

like image 9
Sethu Avatar answered Oct 19 '22 05:10

Sethu


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) {
    ...
like image 6
Solo.dmitry Avatar answered Oct 19 '22 05:10

Solo.dmitry


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
like image 4
Son Andreas Avatar answered Oct 19 '22 05:10

Son Andreas


this helped me :

downgrade to Composer 1 using

composer self-update --1 
like image 2
saber tabatabaee yazdi Avatar answered Oct 19 '22 07:10

saber tabatabaee yazdi


I also faced the same issue and the following code worked for me

  1. rm -rf composer.lock
  2. rm -rf vendor
  3. composer install
like image 2
sajjadkhan Avatar answered Oct 19 '22 05:10

sajjadkhan