Issue: command fails when i run php artisan schedule:run
I am getting the following error when i run php artisan schedule:run
There are no commands defined in the "xxxxx" namespace. {"exception":"[object] (Symfony\Component\Console\Exception\NamespaceNotFoundException(code: 0):
Both my command and app.php files look okay. I am using withschedule like
i have the signature defined correctly but still getting the error. when i run schedule:run it shows
2026-06-17 16:08:47 Running ["artisan" xxxxx:xxxxx].....DONE
then the log files show the error.
Ok, show command file and path to it. It should be under app/Console/Commands and command class should extend \Illuminate\Console\Command. Or you have to register a closure in routes/console.php.
I did the same on fresh Laravel 12.62 and it works fine:
> php artisan make:command OverdueInvoicePenalty --command=overdue:invoice-penalty
INFO Console command [...\app\Console\Commands\OverdueInvoicePenalty.php] created successfully.
> php artisan list overdue
Available commands for the "overdue" namespace:
overdue:invoice-penalty Command description
just to mention. This wasn't a fresh laravel 12x install but an updrade from 9x. Maybe i missed something but i did go through the docs and made sure i moved everything as needed. Everything else is working just fine apart from this only.
So after trying everything i settled for reverting to using the console kernel file and placed the commands there under the schedule function. i also got rid of ->withCommands( and ->withSchedule( in the bootstrap app.php file. i will have to use this as a temporary solution. Thanks to everyone who suggested a fix for this.
Keep in mind old style Kernel scheduling may be dropped in one of upcoming versions and you will have problems with Laravel upgrades. Better settle it now, before big trouble comes.