laravel/framework · error · CommandNotFoundException

The command "%s" does not exist.

Error message

The command "%s" does not exist.

What it means

Thrown by Application::call() (src/Illuminate/Console/Application.php:162) — the Artisan call() helper — when the resolved command name is not registered with the console application. Symfony's CommandNotFoundException is thrown after $this->has($command) returns false.

Source

Thrown at src/Illuminate/Console/Application.php:162

        static::$bootstrappers = [];
    }

    /**
     * Run an Artisan console command by name.
     *
     * @param  \Symfony\Component\Console\Command\Command|string  $command
     * @param  array  $parameters
     * @param  \Symfony\Component\Console\Output\OutputInterface|null  $outputBuffer
     * @return int
     *
     * @throws \Symfony\Component\Console\Exception\CommandNotFoundException
     */
    public function call($command, array $parameters = [], $outputBuffer = null)
    {
        [$command, $input] = $this->parseCommand($command, $parameters);

        if (! $this->has($command)) {
            throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $command));
        }

        return $this->run(
            $input, $this->lastOutput = $outputBuffer ?: new BufferedOutput
        );
    }

    /**
     * Parse the incoming Artisan command and its input.
     *
     * @param  \Symfony\Component\Console\Command\Command|string  $command
     * @param  array  $parameters
     * @return array<string, \Symfony\Component\Console\Input\ArrayInput>
     */
    protected function parseCommand($command, $parameters)
    {
        if (is_subclass_of($command, SymfonyCommand::class)) {
            $callingClass = true;

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Verify the command is registered: run php artisan list and grep for the name.
  2. Register the command class in your Kernel or service provider's commands() array.
  3. Check for typos and the exact name returned by getName()/the $signature property.
  4. If testing, ensure Artisan::call runs after the kernel boots the command, or use $this->artisan('name') in tests.
  5. If using a package, ensure its ServiceProvider is in config/app.php providers list.

Example fix

// before
Artisan::call('reports:send-daily');  // not registered

// after
// in app/Console/Kernel.php -> protected $commands = [\App\Console\Commands\SendDailyReports::class];
Artisan::call('reports:send-daily');
Defensive patterns

Strategy: validation

Validate before calling

$name = 'reports:send';
if (! \Illuminate\Support\Facades\Artisan::has($name)) {
    // register or guard before calling
}

Type guard

function commandRegistered(\Illuminate\Console\Application $app, string $name): bool
{
    return $app->has($name);
}

Try / catch

use Symfony\Component\Console\Exception\CommandNotFoundException;
try {
    \Illuminate\Support\Facades\Artisan::call('reports:send');
} catch (CommandNotFoundException $e) {
    // register/typo fallback
}

Prevention

When it happens

Trigger: Calling Artisan::call('foo:bar') where foo:bar is not a registered command; passing a typo'd command name; calling a command that lives in a service provider that hasn't been loaded (e.g. deferred provider, or env APP_ENV mismatch); calling a command by class FQN that isn't registered via commands() or Kernel.

Common situations: Running tests that invoke Artisan::call() without first registering the command (missing $this->commands[] in a test kernel), typos in command signatures, package commands not registered because the package's ServiceProvider wasn't added to config/app.php.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/27ef1a602efd57d6.json. Report an issue: GitHub.