4

I am getting error at running composer dump-autoload at laravel project

composer dump-autoload
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
You made a reference to a non-existent script @php artisan package:discover

Then executing php artisan package:discover returns

Discovered Package: barryvdh/laravel-ide-helper
Discovered Package: cartalyst/sentinel
Discovered Package: laravelcollective/html
Discovered Package: laracasts/generators
Package manifest generated successfully.

Then again getting the same error

composer dump-autoload
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
You made a reference to a non-existent script @php artisan package:discover

What may be wrong? composer self-update or composer global update not helping.

Syed Waqas Bukhary
  • 5,130
  • 5
  • 47
  • 59

5 Answers5

10

Okay, I think that composer dump-autoload is working even with that warning. (thanks to the user:Sohel0415 comments) composer was not able to run script with @ symbol in composer.json file.

If you want to get rid of this warning simply do

composer dump-autoload --no-scripts

or

you may delete the script with @ "post-autoload-dump": [] from you "scripts": {} in the composer.json file temporarily, and it should be all good.

Syed Waqas Bukhary
  • 5,130
  • 5
  • 47
  • 59
4

You may also try to update your global composer package with this command.

composer self-update

I was having this error because I had an old version of composer that wasn't reading the @ symbols.

  • This solution worked for me. The Docker container was running an older version of composer, so had to rebuild it to install the current latest version. – Matt Inamdar Jul 10 '19 at 10:18
1

For myself, I found that in composer.json I had the wrong references to the php command: I changed the lines that specified a location for php, for example:

"@/usr/local/bin/php artisan key:generate"

to:

"@php artisan key:generate"

After those changes, I was able to execute the command "composer update" with no error.

zardox
  • 41
  • 5
0

I have changed

 "scripts": {
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@/usr/local/bin/php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
        "@/usr/local/bin/php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@/usr/local/bin/php artisan key:generate --ansi"
    ]
}

to

"scripts": {
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
        "@/usr/local/bin/php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate --ansi"
    ]
}

in composer.json

Sandi Horvat
  • 407
  • 1
  • 6
  • 17
0

I just had this issue trying to add composer native cache-clear command to a custom script I made called composer nuke. I was using it as @clear-cache and got the message, "You made a reference to a non-existent script @clear-cache".

I guess the @ symbol is only for custom commands. I had to put composer cache-clear inside the custom command and the error was resolved and the command ran as expected then.

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91