{"id":"31abd383ab5d1920","repo":"laravel/framework","slug":"cache-store-name-is-not-defined","errorCode":null,"errorMessage":"Cache store [{$name}] is not defined.","messagePattern":"Cache store \\[(.+?)\\] is not defined\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Cache/CacheManager.php","lineNumber":121,"sourceCode":"        });\n\n        return $this->app->make($bindingKey);\n    }\n\n    /**\n     * Resolve the given store.\n     *\n     * @param  string  $name\n     * @return \\Illuminate\\Contracts\\Cache\\Repository\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function resolve($name)\n    {\n        $config = $this->getConfig($name);\n\n        if (is_null($config)) {\n            throw new InvalidArgumentException(\"Cache store [{$name}] is not defined.\");\n        }\n\n        $config = Arr::add($config, 'store', $name);\n\n        return $this->build($config);\n    }\n\n    /**\n     * Build a cache repository with the given configuration.\n     *\n     * @param  array  $config\n     * @return \\Illuminate\\Cache\\Repository\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function build(array $config)\n    {\n        $config = Arr::add($config, 'store', $config['name'] ?? 'ondemand');","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Cache/CacheManager.php#L103-L139","documentation":"CacheManager::resolve() reads cache.stores.{name} from config; if it returns null the store name is unknown and an InvalidArgumentException is thrown. The store name comes from Cache::store('name'), Cache::store(SomeEnum::Foo), the default driver, or Cache::getProvider('name').","triggerScenarios":"Calling Cache::store('myredis')->get('k') when 'myredis' is not listed under 'stores' in config/cache.php. The CACHE_STORE/CACHE_DRIVER env var resolves to a name that has no entry. Using an enum value whose name isn't configured.","commonSituations":"Typo in .env CACHE_STORE=rediss. Renaming a store in config but forgetting to update CACHE_STORE. Referencing a store in code that only exists in another environment's config. Caching config (php artisan config:cache) with an outdated CACHE_STORE before adding the store definition.","solutions":["Add the store under 'stores' in config/cache.php with at least a 'driver' key.","Correct the typo in .env CACHE_STORE (or CACHE_DRIVER on older versions) to match the store name.","Clear config cache: php artisan config:clear, then re-cache after fixing.","If using an enum, ensure the enum value matches the configured store key exactly."],"exampleFix":"// before\n// .env: CACHE_STORE=rediss\n// config/cache.php 'stores' has no 'rediss'\n\n// after\n// .env: CACHE_STORE=redis\n'stores' => [\n    'redis' => [\n        'driver' => 'redis',\n        'connection' => 'cache',\n    ],\n],","handlingStrategy":"validation","validationCode":"$name = config('cache.default');\nif (! config(\"cache.stores.{$name}\")) {\n    throw new \\RuntimeException(\"Cache store [{$name}] is not configured.\");\n}\nCache::store($name)->get('k');","typeGuard":"function cacheStoreIsDefined(string $name): bool\n{\n    return config(\"cache.stores.{$name}\") !== null;\n}","tryCatchPattern":"try {\n    return Cache::store($name)->get('k');\n} catch (\\InvalidArgumentException $e) {\n    if (str_contains($e->getMessage(), 'is not defined')) {\n        // fall back to default driver or add the store config\n        return Cache::get('k');\n    }\n    throw $e;\n}","preventionTips":["Validate cache store names against config in a boot-time check.","Document every CACHE_STORE value used per environment.","Run config:clear after adding/removing stores.","Add a test asserting required stores exist."],"tags":["cache","configuration","env","config-cache"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}