{"id":"6ea771bdd6593cc8","repo":"laravel/framework","slug":"command-s-does-not-exist","errorCode":null,"errorMessage":"Command \"%s\" does not exist.","messagePattern":"Command \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"CommandNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Console/ContainerCommandLoader.php","lineNumber":49,"sourceCode":"     */\n    public function __construct(ContainerInterface $container, array $commandMap)\n    {\n        $this->container = $container;\n        $this->commandMap = $commandMap;\n    }\n\n    /**\n     * Resolve a command from the container.\n     *\n     * @param  string  $name\n     * @return \\Symfony\\Component\\Console\\Command\\Command\n     *\n     * @throws \\Symfony\\Component\\Console\\Exception\\CommandNotFoundException\n     */\n    public function get(string $name): Command\n    {\n        if (! $this->has($name)) {\n            throw new CommandNotFoundException(sprintf('Command \"%s\" does not exist.', $name));\n        }\n\n        return $this->container->get($this->commandMap[$name]);\n    }\n\n    /**\n     * Determines if a command exists.\n     *\n     * @param  string  $name\n     * @return bool\n     */\n    public function has(string $name): bool\n    {\n        return $name && isset($this->commandMap[$name]);\n    }\n\n    /**\n     * Get the command names.","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Console/ContainerCommandLoader.php#L31-L67","documentation":"Thrown by ContainerCommandLoader::get() (src/Illuminate/Console/ContainerCommandLoader.php:49) when Symfony's console asks for a command name not present in the command map. The loader is a lazy registry; has() checks isset($this->commandMap[$name]).","triggerScenarios":"Symfony Console resolves a command lazily via the loader (typically via Application::find/get) and the name is absent from the commandMap passed to the loader at construction time.","commonSituations":"Building a standalone Symfony Console app wired with Illuminate's ContainerCommandLoader and forgetting to add the command to the map, or referencing an alias not present in the map.","solutions":["Add the command name => class binding to the commandMap array passed to ContainerCommandLoader.","Use the Application::add() convenience instead of lazy loading for simple cases.","Verify command name with $loader->has($name) before calling $loader->get($name).","Ensure the command's getName() matches the key in the map."],"exampleFix":"// before\n$loader = new ContainerCommandLoader($container, [\n    'migrate' => MigrateCommand::class,\n]);\n$loader->get('migrate:fresh');  // missing\n\n// after\n$loader = new ContainerCommandLoader($container, [\n    'migrate' => MigrateCommand::class,\n    'migrate:fresh' => MigrateFreshCommand::class,\n]);","handlingStrategy":"validation","validationCode":"if (! $loader->has($name)) {\n    // command missing from commandMap; add it before calling get()\n}","typeGuard":"// has() is itself the guard\n$exists = $loader->has($name);","tryCatchPattern":"use Symfony\\Component\\Console\\Exception\\CommandNotFoundException;\ntry {\n    $cmd = $loader->get($name);\n} catch (CommandNotFoundException $e) {\n    // fall back to a default command or error\n}","preventionTips":["Populate commandMap with every name returned by getName().","Call has() before get() in dynamic dispatch paths.","Keep Application::add() for small apps to avoid manual map maintenance."],"tags":["console","symfony-console","command-not-found","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}