laravel/framework · error · InvalidArgumentException

Driver [ ] is not supported.

Error message

Driver [{$config['driver']}] is not supported.

What it means

CacheManager::build dispatches to a create{Driver}Driver method (e.g., createRedisDriver) or to a custom creator registered via Cache::extend(). If neither exists for the configured 'driver' string, the build is aborted. The supported built-in drivers are: apc, array, database, file, dynamodb, memcached, redis, null (and 'session' for the session-backed cache).

Solutions

  1. Set CACHE_DRIVER (or the 'driver' key in config/cache.php) to a supported value: apc, array, database, file, dynamodb, memcached, redis, or null.
  2. If using a custom driver, register it via Cache::extend('your-driver', fn ($app, $config) => new Repository(...)) in a boot() method of a service provider that is actually registered.
  3. Run php artisan config:clear to drop stale config cache after edits.
  4. Verify the driver name spelling and case match exactly (ucfirst is applied, but the lookup key is the raw string).

Example fix

// before (config/cache.php)
'stores' => [
    'default' => [
        'driver' => 'muyredis', // typo
        'connection' => 'cache',
    ],
],

// after
'stores' => [
    'default' => [
        'driver' => 'redis',
        'connection' => 'cache',
    ],
],

// OR register a custom driver in AppServiceProvider::boot()
Cache::extend('myredis', function ($app, array $config) {
    return Cache::repository(new \My\CustomRedisStore($config));
});
Defensive patterns

Strategy: validation

Validate before calling

// Validate the driver is supported before building
$driver = config('cache.stores.default.driver');
$supported = ['apc','array','database','dynamodb','file','memcached','redis','null','session'];
if (! in_array($driver, $supported, true) && ! app(\Illuminate\Cache\CacheManager::class)->hasCustomCreator($driver)) {
    throw new \RuntimeException("Cache driver [{$driver}] is not supported.");
}

Type guard

function cacheDriverIsSupported(string $driver): bool
{
    $builtIn = ['apc','array','database','dynamodb','file','memcached','redis','null','session'];
    return in_array($driver, $builtIn, true)
        || array_key_exists($driver, app(\Illuminate\Cache\CacheManager::class)->getCustomCreators());
}

Try / catch

try {
    Cache::store('default')->get('key');
} catch (\InvalidArgumentException $e) {
    if (str_starts_with($e->getMessage(), 'Driver [')) {
        // fall back to array driver
        return Cache::store('array')->get('key');
    }
    throw $e;
}

Prevention

When it happens

Trigger: Setting CACHE_DRIVER=foo (or 'driver' => 'foo' in config/cache.php) where 'foo' is neither a built-in driver nor registered via Cache::extend('foo', ...). Also when a custom driver name was typo'd in config or in a Cache::extend() call.

Common situations: Missing PHP extension for a driver (e.g., 'memcached' without ext-memcached) — note this surfaces as a different error, but 'imaginary' driver names hit this one. Stale cached config from a deleted driver. Custom driver registered in a service provider that didn't load (provider not in config/app.php providers array).

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/c5cd88ff8edd98e9. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Cache/CacheManager.php:151

     * @return \Illuminate\Cache\Repository
     *
     * @throws \InvalidArgumentException
     */
    public function build(array $config)
    {
        $config = Arr::add($config, 'store', $config['name'] ?? 'ondemand');

        if (isset($this->customCreators[$config['driver']])) {
            return $this->callCustomCreator($config);
        }

        $driverMethod = 'create'.ucfirst($config['driver']).'Driver';

        if (method_exists($this, $driverMethod)) {
            return $this->{$driverMethod}($config);
        }

        throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported.");
    }

    /**
     * Call a custom driver creator.
     *
     * @param  array  $config
     * @return mixed
     */
    protected function callCustomCreator(array $config)
    {
        return $this->customCreators[$config['driver']]($this->app, $config);
    }

    /**
     * Create an instance of the APC cache driver.
     *
     * @param  array  $config
     * @return \Illuminate\Cache\Repository

View on GitHub (pinned to e0f6eb3518)