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

kevbrn's avatar
Level 14

There are no commands defined in the "command" namespace.

I have created some commands in my application and I registered them in Console/Commands/Kernel.php

 protected $commands = [
        Commands\ClearNotificationsTable::class,
        Commands\ClearTasksFromNotifications::class,       
    ];

Yet when I try to execute them via artisan php artisan command:ClearNotificationsTable I get the following error.

"There are no commands defined in the "command" namespace."

The command files are all located in Console/Commands

Any ideas?

0 likes
9 replies
tykus's avatar

You execute Artisan commands using the name you specify in the Command class.

kevbrn's avatar
Level 14

Ya that's what I am doing.

php artisan command:ClearNotificationsTable

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class ClearNotificationsTable extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:ClearNotificationsTable';

tykus's avatar

If you run php artisan list, do you see your commands in the output?

Also, you do not have to manually register the commands if they are inside the App\Console\Commands namespace already - they are automatically registered by default.

mfoote's avatar

Did you create the commands via...

php artisan make:command --command=command:ClearNotificationsTable

I did a test with the same naming in 5.5 and it worked fine... just curious if the command is not in the correct directory.

kevbrn's avatar
Level 14

@tykus No they do not. Which is odd.

@mfoote I believe I did it as

php artisan make:command ClearNotificationsTable

They are located in App\Console\Commands

tykus's avatar

Can you show us your entire kernel file?

kevbrn's avatar
Level 14
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        Commands\ClearTasksFromNotifications::class,
        Commands\ClearNotificationsTable::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
         $schedule->command('command:ClearNotificationsTable')
             ->weekly()->mondays()->at('08:00');
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

bed's avatar

Or you can add in appServiceProvider class as:

 $this->commands([
            JobNotificationSendCommand::class
        ]);
Sinnbeck's avatar

Can you show the full command? There might be a syntax error making the file unreadable

Please or to participate in this conversation.