I'm building out a Shedquarters in my backyard! Check out the ever-evolving post + pictures here →

Fixing "Laravel PackageManifest.php: Undefined index: name" in GitHub Actions

January 26, 2021

If you're running into the Laravel PackageManifest.php: Undefined index: name error in Laravel, there are a couple of ways to fix it.

First, the issue is that Composer 2 changed the format of their installed.json that is causing Laravel to not be able to find the installed packages. If you've been googling this error, you've probably already come across this issue, but here it is in case you haven't seen it yet: github.com/composer/issues/9340.

Laravel has updated to handle the new format, so the easiest way to fix it would be to update Laravel if you can: composer update laravel/framework.

If you can't update Laravel for whatever reason, you can roll back your Composer version to 1 by running composer self-update --1. That will revert the installed.json version back to a format your old Laravel version is comfortable with.

Fixing for GitHub Actions

If you're developing a package you may be testing with --prefer-lowest and --prefer-stable flags, so you can test the lowest version of a Laravel release and the most recent version. You also don't want to use Composer 1 all the time because it's quite a bit slower than Composer 2.

In that case, your workflow file may look a bit like this:

2 test:
3 runs-on: ubuntu-latest
4 strategy:
5 matrix:
6 laravel: [ 7.*, 8.* ]
7 dependency-version: [ prefer-lowest, prefer-stable ]
9 steps:
10 - name: Install dependencies
11 run: |
12 composer require "laravel/framework:$@{{ matrix.laravel }}" "orchestra/testbench:$@{{ matrix.testbench }}" --no-interaction --no-update
13 composer update --$@{{ matrix.dependency-version }} --prefer-dist --no-interaction
15 - name: Execute tests
16 run: vendor/bin/phpunit
Code highlighting powered by torchlight.dev.

Here we're telling GitHub to run the tests on

  • Laravel 7 lowest
  • Laravel 7 stable
  • Laravel 8 lowest
  • Laravel 8 stable

The problem is that Laravel 7 --lowest has this undefined index problem, and we don't want to update because we're specifically testing the oldest version here.

By adding an include section, we can inject a variable whenever we're running the tests for 7 --lowest. Specifically, we're going to inject composer-version: --1 here, so when we're running 7 --lowest we'll use the old version of composer.

In our Install Dependencies section we'll add a line to update Composer, taking our new variable into account: composer self-update $@{{ matrix.composer-version }}.

2 test:
3 runs-on: ubuntu-latest
4 strategy:
5 matrix:
6 laravel: [ 7.*, 8.* ]
7 dependency-version: [ prefer-lowest, prefer-stable ]
8 include:
9 - laravel: 7.*
10 dependency-version: prefer-lowest
11 # Use Composer 1 with Laravel 7 --lowest
12 composer-version: --1
14 name: P$@{{ matrix.php }} - L$@{{ matrix.laravel }} - $@{{ matrix.dependency-version }}
16 steps:
17 - name: Install dependencies
18 run: |
19 composer self-update $@{{ matrix.composer-version }}
20 composer require "laravel/framework:$@{{ matrix.laravel }}" "orchestra/testbench:$@{{ matrix.testbench }}" --no-interaction --no-update
21 composer update --$@{{ matrix.dependency-version }} --prefer-dist --no-interaction
23 - name: Execute tests
24 run: vendor/bin/phpunit

Now we're only using Composer 1 when we absolutely have to, so we get the speed/memory benefits of Composer 2 otherwise, and we've fixed the undefined index issue.

Hope that helps!

Thanks for reading! My name is Aaron and I'm currently working at small property tax firm in Texas, where I serve in dual roles as COO & CTO.

I work on a lot of projects. I'm building a shedquarters. I currently do a podcast, and I used to do a different podcast.

If you ever have any questions or want to chat, I'm always on Twitter
Copyright 2013 - 2021, Aaron Francis.