laravel/framework · error · InvalidArgumentException

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

Error message

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

What it means

CacheManager::build() looks for a custom creator registered via extend(), then for a create{Driver}Driver method; if neither exists it throws InvalidArgumentException. The driver value comes from the store's 'driver' config key and must map to a built-in driver or a registered custom one.

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 bd6b5437e6)

Solutions

  1. Fix the 'driver' spelling in config/cache.php to a supported name (file, redis, database, array, null, dynamodb, memcached, apc, etc.).
  2. Install the required composer/extension for that driver (e.g. composer require aws/aws-sdk-php for dynamodb).
  3. For custom drivers, call Cache::extend('name', fn ...) inside a booted ServiceProvider boot() method and run config:clear.
  4. Run php artisan config:clear to drop a stale config cache that lacks the extend registration.

Example fix

// before
'stores' => [
    'my' => [
        'driver' => 'custm',
        'path' => storage_path('framework/cache/data'),
    ],
],

// after
'stores' => [
    'my' => [
        'driver' => 'file',
        'path' => storage_path('framework/cache/data'),
    ],
],
// or register: Cache::extend('custm', fn($app,$config) => ...);
Defensive patterns

Strategy: validation

Validate before calling

$driver = config('cache.stores.my.driver');
$supported = ['array','file','redis','database','dynamodb','memcached','apc','null'];
if (! in_array($driver, $supported, true) && ! app('cache')->getDrivers()->has($driver)) {
    throw new \RuntimeException("Unsupported cache driver [{$driver}].");
}

Type guard

function cacheDriverIsSupported(string $driver): bool
{
    $builtin = ['array','file','redis','database','dynamodb','memcached','apc','null','failover','storage'];
    return in_array($driver, $builtin, true)
        || app()->bound("cache.extend.{$driver}");
}

Try / catch

try {
    Cache::store('my')->get('k');
} catch (\InvalidArgumentException $e) {
    if (str_contains($e->getMessage(), 'is not supported')) {
        // fix driver spelling or install dependency, then config:clear
    }
    throw $e;
}

Prevention

When it happens

Trigger: Setting 'driver' => 'dynamodb' in a store but not having the aws/aws-sdk-php dependency. Typing the driver name (e.g. 'memcashed'). Registering a custom driver via Cache::extend() after config is cached, or in a service provider that didn't run.

Common situations: Missing PHP extension or composer package for a driver (apcu, memcached, dynamodb). Custom driver extend() call placed in a non-booted provider or removed by refactoring. Case-sensitivity mistakes (driver names are lowercased via ucfirst only on the method name).

Related errors


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