Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

robmac's avatar
Level 17

Laravel 9 upgrade / composer update / bootstrap cache problem

After making the required changes to my composer.json file and running composer update I get the following error:

 ERROR  There are no commands defined in the "package" namespace. 
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

When running php artisan list, there are several commands missing, including package:discover. Digging deeper, I discovered that the missing commands are consistent with the 'deferred' array in the bootstrap/cache/services.php file.

If I clear the bootstrap cache rm -rf bootstrap/cache/* before running composer update , the cache files are regenerated and result in the same error message (above).

What have I done wrong? What don't I understand?

From my Googling, I have discounted the following suggestions: app\Exceptions\Handler.php Throwable changes (changed during a previous upgrade), TrustedProxies Middleware (suggested changes already applied).

Any ideas? I am upgrading from Laravel 8 to 9.

0 likes
10 replies
robmac's avatar
Level 17

@shaungbhone

{
	"name": "laravel/laravel",
	"description": "The Laravel Framework.",
	"keywords": ["framework", "laravel"],
	"license": "MIT",
	"type": "project",
	"require": {
		"php": "^8.0.2",
		"barryvdh/laravel-snappy": "1.0.*",
		"bugsnag/bugsnag-laravel": "^2.0",
		"doctrine/dbal": "~2.5",
		"fakerphp/faker": "^1.9.1",
		"fruitcake/laravel-cors": "^2.0",
		"guzzlehttp/guzzle": "^7.0.1",
		"h4cc/wkhtmltopdf-amd64": "0.12.2.1",
		"intervention/image": "~2.1.1",
		"laravel/framework": "^9.0",
		"laravel/helpers": "^1.0@dev",
		"laravel/tinker": "^2.0",
		"laravel/ui": "^3.0@dev",
		"laravelcollective/html": "6.3.*",
		"league/csv": "~7.0",
		"league/flysystem-aws-s3-v3": "^3.0",
		"league/flysystem-sftp-v3": "^3.0",
		"livewire/livewire": "^2.10",
		"marfrelen/lessphp": "^0.5.1",
		"pda/pheanstalk": "~4.0",
		"predis/predis": "~1.0",
		"simplepie/simplepie": "~1.3",
		"snowfire/beautymail": "dev-master",
		"suin/php-rss-writer": "~1.3",
		"symfony/http-client": "^6.0",
		"symfony/mailgun-mailer": "^6.0",
		"symfony/postmark-mailer": "^6.0"
	},
	"require-dev": {
		"spatie/laravel-ignition": "^1.0",
		"barryvdh/laravel-debugbar": "^3.3",
		"beyondcode/laravel-dump-server": "^1.7",
		"filp/whoops": "^2.0",
		"itsgoingd/clockwork": "^5.0",
		"mockery/mockery": "^1.0",
		"nunomaduro/collision": "^6.1",
		"phpunit/phpunit": "^9.3",
		"roave/security-advisories": "dev-master"
	},
	"autoload": {
		"psr-4": {
			"****\****\": "app/",
			"Database\Factories\": "database/factories/",
			"Database\Seeders\": "database/seeders/"
		}
	},
	"autoload-dev": {
		"psr-4": {
			"Tests\": "tests/"
		},
		"files": [
			"app/helpers.php"
		]
	},
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
	"config": {
		"preferred-install": "dist",
		"sort-packages": true,
		"optimize-autoloader": true,
		"platform": {
			"php": "8.0.2"
		}
	},
    "prefer-stable": true,
	"minimum-stability": "dev"
}
shaungbhone's avatar

And here is my laravel 9 composer.json

"scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
robmac's avatar
Level 17

@shaungbhone Thanks.

I have tried changing the order of the scripts and adding the --ansi flags, but still getting the same error.

robmac's avatar
Level 17

@shaungbhone Yep. Bumped it to version 4, but made no difference to the error message.

It must have something to do with whatever is auto-generating the bootstrap cache, but I can't figure it out.

Please or to participate in this conversation.