symfony/http-foundation · error · InvalidArgumentException
Unsupported Redis or Memcached DSN. Try running "composer…
Error message
Unsupported Redis or Memcached DSN. Try running "composer require symfony/cache".
What it means
An InvalidArgumentException thrown by SessionHandlerFactory::createHandler() when the DSN string starts with redis:, rediss:, valkey:, valkeys: or memcached: but symfony/cache (which provides AbstractAdapter used to build the client) is not installed. Like the other LogicException-style dependency guards, it reports a missing package, not a malformed DSN.
Solutions
- Run composer require symfony/cache so Redis/Memcached DSNs can be converted into connections
- Create the Redis/Memcached client manually (\Redis, Predis, \Memcached) and pass the object to the factory instead of a DSN
- Choose a different session save handler (e.g. file:// or a PDO DSN) that needs no extra package
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at Session/Storage/Handler/SessionHandlerFactory.php:64 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of symfony/http-foundation@5aea19cd67 (2026-09-13).
Data as JSON: /api/errors/e24e72a0adc5ae3a.
Report an issue: GitHub.
Appendix: source
Thrown at Session/Storage/Handler/SessionHandlerFactory.php:64
case str_starts_with($connection, 'redis:'):
case str_starts_with($connection, 'rediss:'):
case str_starts_with($connection, 'valkey:'):
case str_starts_with($connection, 'valkeys:'):
case str_starts_with($connection, 'memcached:'):
if (!class_exists(AbstractAdapter::class)) {
throw new \InvalidArgumentException('Unsupported Redis or Memcached DSN. Try running "composer require symfony/cache".');
}
$handlerClass = str_starts_with($connection, 'memcached:') ? MemcachedSessionHandler::class : RedisSessionHandler::class;
$connection = preg_replace('/([?&])prefix=[^&]*+&?/', '\1', $connection);
$connection = AbstractAdapter::createConnection($connection, ['lazy' => true]);
return new $handlerClass($connection, array_intersect_key($options, ['prefix' => 1, 'ttl' => 1]));View on GitHub (pinned to 5aea19cd67)