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

tbonete's avatar

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

I'm having a craftsman error after changing the version of Composer version 2.0.7 2020-11-13 17:31:06 error

Generating optimized autoload files

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

RuntimeException : Unable to detect application namespace.

at /var/www/cenci/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1217 1213| } 1214| } 1215| } 1216|

1217| throw new RuntimeException('Unable to detect application namespace.'); 1218| } 1219| } 1220|

Exception trace:

1 Illuminate\Foundation\Application::getNamespace() /var/www/cenci/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:232

2 Illuminate\Foundation\Console\Kernel::load() /var/www/cenci/app/App/Console/Kernel.php:42

Please use the argument -v to see more details. Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

my composer.json

{ "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "require": { "php": "^7.1.3", "barryvdh/laravel-dompdf": "^0.8.6", "barryvdh/laravel-ide-helper": "^2.7", "doctrine/dbal": "^2.10", "fideloper/proxy": "^4.0", "fzaninotto/faker": "^1.9", "intervention/image": "^2.4", "jansenfelipe/faker-br": "^1.0", "laravel/framework": "5.8.*", "laravel/tinker": "^1.0", "liorchamla/faker-prices": "^1.0", "maatwebsite/excel": "^3.1", "magyarjeti/laravel-lipsum": "^1.1", "mll-lab/laravel-graphql-playground": "^2.4", "mpdf/mpdf": "^8.0", "nuwave/lighthouse": "^4.18", "pusher/pusher-php-server": "^4.1", "renatomarinho/laravel-page-speed": "^1.8", "rodenastyle/stream-parser": "^1.3", "shiftonelabs/laravel-cascade-deletes": "^1.0", "yajra/laravel-datatables-oracle": "^9.8" }, "require-dev": { "beyondcode/laravel-dump-server": "^1.0", "filp/whoops": "^2.0", "mockery/mockery": "^1.0", "mpociot/laravel-apidoc-generator": "^4.3", "nunomaduro/collision": "^3.0", "phpunit/phpunit": "^7.5" }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "extra": { "laravel": { "dont-discover": [] } }, "autoload": { "psr-4": { "App\": "App/" }, "classmap": [ "database/seeds", "database/factories" ], "files": [ "App/Helpers/functions.php" ] }, "autoload-dev": { "psr-4": { "Tests\": "Tests/" } }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r "file_exists('.env') || copy('.env.example', '.env');"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] } }

version of my php

PHP 7.4.12 (cli) (built: Oct 31 2020 17:04:09) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with the ionCube PHP Loader + ionCube24 v10.4.4, Copyright (c) 2002-2020, by ionCube Ltd. with Zend OPcache v7.4.12, Copyright (c), by Zend Technologies with SourceGuardian v11.4.1, Copyright (c) 2000-2020, by SourceGuardian Ltd.

seems to be something related to psr-4

0 likes
1 reply
isa's avatar
"psr-4": { "App\": "App/" }, 

Should probably be

"psr-4": { "App\\": "app/" }, 

just like that)

Please or to participate in this conversation.