ResamkitheDeveloper's avatar

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

->withSchedule(function (Schedule $schedule) { $schedule->command('xxxxx:xxxxx')->daily(); })

I am on laravel 12.62.0

what could i be missing?

0 likes
18 replies
aleahy's avatar

Make sure you have defined the signature correctly for the console command:

protected $signature = 'xxxxx:xxxxx';

The part before the colon is the namespace the error message is talking about.

So if your signature was app:test, then app would be the namespace.

If you defined your signature as just xxxxx then it would be expecting the command to just be xxxxx.

ResamkitheDeveloper's avatar

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.

Glukinho's avatar

i have the signature defined correctly

Show it maybe? Without masked letters. Full command file is better.

Glukinho's avatar

Can you share the whole command file?

What php artisan list overdue gives you?

Glukinho's avatar

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.

ResamkitheDeveloper's avatar

the command file name is OverdueInvoicePenalty.php and i already have this in it

namespace App\Console\Commands;

use Illuminate\Console\Command;

class OverdueInvoicePenalty extends Command {....}

Glukinho's avatar

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

Scheduling in app.php works too:

->withSchedule(function (Schedule $schedule) {
    $schedule->command('overdue:invoice-penalty')->daily();
})
> php artisan schedule:list

  0 0 * * *  php artisan overdue:invoice-penalty ...

Do you have something unwanted in bootstrap/app.php or app/Providers/AppServiceProvider.php or routes/console.php?

ResamkitheDeveloper's avatar

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.

JussiMannisto's avatar

Are you registering the commands? In older versions it was done in app/Console/Kernel.php.

1 like
JussiMannisto's avatar

It sounds like it should work. Here are some things you could check if you're out of ideas:

  1. Do you have anything funky in your app/bootstrap.php file, such as a custom ->withCommands() call?
  2. Are you still manually registering a Kernel class somewhere? Search for occurrences of Kernel::class under app/ and bootstrap/.
  3. You can always try running composer dump-autoload and php artisan optimize:clear, in case the autoload file or some caches are stale.
1 like
ResamkitheDeveloper's avatar
  1. I don't have ->withCommands(). i however have ->withSchedule(function (Schedule $schedule) {...} and when i run php artisan schedule:list i get this
          • php artisan overdue:invoice-penalty ..................................... Next Due: 37 seconds from now
  1. No

  2. i did this several times and it still does not work

Glukinho's avatar

Try to remove ->withSchedule() and define schedule in routes/console.php. Does it work?

Also please format code or command output by wrapping it with three backticks.

Glukinho's avatar

Try to create new command from scratch:

php artisan make:command TestCommand --command=app:test

and define a schedule for it. Does it work?

Please or to participate in this conversation.