相关文章推荐
逃课的滑板  ·  Python Flask ...·  1 年前    · 
爱搭讪的皮带  ·  android ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

Ask Question

Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 0 installs, 0 updates, 1 removal - Removing genealabs/laravel-caffeine (0.3.12) Writing lock file Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'GeneaLabs\LaravelCaffeine\LaravelCaffeineServiceProvider' not found

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I occasionally get this error, so far I've found that simply executing the command again works. composer dump autoload liamvictor Mar 12, 2019 at 10:30 @liamvictor I believe you meant to say composer dump-autoload , just in case anyone comes across this. Colin May 14, 2020 at 18:49 That's worked for me. Running the command php artisan package:discover --ansi by itself might tell you more about the issue. MsM Robin Jun 21, 2021 at 9:44 This should be the accepted answer - dont fiddle with files just update the composer and it does it for you... works like a charm. alex toader Nov 10, 2020 at 9:58 I receive this message already at the end of the composer update command. So, running it again doesn't solve the problem. mdikici Nov 29, 2021 at 12:35

Add this in composer.json . Then dusk has to be installed explicitly in your project:

"extra": {
    "laravel": {
        "dont-discover": [
            "laravel/dusk"

I found this solution here

In case you're coming from a google search, make sure that you have a .env file in which APP_ENV is set to local. (if you cloned a project from github, the first thing is to run cp .env.example .env. That was actually the problem in my case)

Then run composer install again.

This solves the problem for me. The .env is replaced by .env.example for project from GitHub. So we need to create it using the .env.example by running the command cp .env.example .evn . The command us just copying the .env.example and set it name by .env – stic-lab Jan 30, 2022 at 8:57

You have added the service provider in config/app.php for the package that is not installed in the system.

You must have this line in your config/app.php. You can either remove it or install the package GeneaLabs\LaravelCaffeine\LaravelCaffeineServiceProvider

See https://github.com/GeneaLabs/laravel-caffeine.

Run the line below via CLI to install the package.

 composer require genealabs/laravel-caffeine

Running the command php artisan package:discover --ansi by itself might tell you more about the issue. In my case correcting a character out of place in the .env solved it.

This is weird the exact same case happen to both of us the same DAY, in my case it was a character in my passport tokens declaration – Danys Chalifour Mar 14, 2021 at 18:02 This was the cause of my issue. A deploy script that installed composer into the current folder if composer was not already on the system installed a 2.0.x version of composer. – Jim OHalloran Dec 14, 2020 at 6:19

I came across this when upgrading from 5.8 to 6.x.

I had str_slug() in config/cache.php and config/session.php.

I have changed it to Str::slug() and the error has disappeared.

See https://laravel.com/docs/6.x/upgrade#helpers.

The environment file is invalid!
Failed to parse dotenv file due to unexpected whitespace. Failed at [my name].
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

Don't use space in APP_NAME key !!

In my case I was trying to remove a package but forgot to remove it from config/app.php providers section hence, the error and this results to being unable to run php artisan and/or composer dumpautoload. Remove bootstrap/cache/config.php file then run composer dumpautoload again. After that php artisan works again just fine. – Dale Ryan Nov 5, 2021 at 3:52 1- add all directories in cache directory "storage\framework\cache\data\cache" 2- Remove bootstrap/cache/config.php file. 3- remove incorrect syntax of .env file – Anas Alpure Jan 27, 2022 at 19:48

You could try

composer update

That worked for me when I had this same issue. In my case what made me discover this issue was when i tried to run the artisan command and it didn't return anything

So I tried composer dumpautoload which threw me this same error mentioned

composer update did the trick

In my case this error happened to me when i removed a package with composer remove, then i realized somehow, something affected my config files in config directory, and they all become empty.

Solution for me was simply getting those files from Laravel repository and copy them into config directory. (and of course in case you need to do vendor publish for specific libraries, you should do it again.)

If none of the solutions work for you, the handling the post-autoload-dump event returned with error code 1 error can also be caused by using Composer 2 instead of Composer 1. That can happen when you run the install command manually in something like a Dockerfile, and it installs newest. Just modify your command to install the last 1.x.x stable version with the --1 option:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --1

Or, specify a certain version with --version=x.x.x:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=1.10.17

It might be good to also delete your vendor directory and composer.lock file so that nothing stale interferes with the version downgrade, before calling composer install as usual.

in my case the problem was into outdated "../bootstrap/cache/packages.php and services.php"

I have had to. drop those files and rerun composer install...

  Erroneous data format for unserializing 'Symfony\Component\Routing\CompiledRoute'
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I have same issue

above this error

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I found one more message in my terminal like: "

"Cartalyst\Stripe\Laravel\StripeServiceProvider::class, not found in your ProviderRepository.php"

then i go config/app.php and find

Cartalyst\Stripe\Laravel\StripeServiceProvider::class

comment it out then run

composer update

it will work fine **In your case maybe package name is different please check your terminal **

In AuthServiceProvider.php line 29: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')' Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

I solved it by upgrading PHP version to 7.4

because i was using Arrow functions in the AuthServiceProvider that came up in 7.4

if you cloned a project from github, the first thing is to run cp .env.example .env.

Then run composer install again.

That was actually the problem in my case

this is idea from @Itope84

Check your code for errors in my case i had an error in Kernel.php. First solve errors if any Than run composer require ....(package you wish)

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.