{"record":{"id":"ca5bd54f87fdc7c5","repo":"symfony/http-foundation","slug":"the-scheme-s-is-not-supported-by-the-pdosessionhandler-url","errorCode":null,"errorMessage":"The scheme \"%s\" is not supported by the PdoSessionHandler URL configuration. Pass a PDO DSN directly.","messagePattern":"The scheme \"(.+?)\" is not supported by the PdoSessionHandler URL configuration\\. Pass a PDO DSN directly\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Session/Storage/Handler/PdoSessionHandler.php","lineNumber":611,"sourceCode":"                $dsn = 'sqlsrv:server=';\n\n                if (isset($params['host'])) {\n                    $dsn .= $params['host'];\n                }\n\n                if (isset($params['port']) && '' !== $params['port']) {\n                    $dsn .= ','.$params['port'];\n                }\n\n                if (isset($params['path'])) {\n                    $dbName = substr($params['path'], 1); // Remove the leading slash\n                    $dsn .= ';Database='.$dbName;\n                }\n\n                return $dsn;\n\n            default:\n                throw new \\InvalidArgumentException(\\sprintf('The scheme \"%s\" is not supported by the PdoSessionHandler URL configuration. Pass a PDO DSN directly.', $params['scheme']));\n        }\n    }\n\n    /**\n     * Helper method to begin a transaction.\n     *\n     * Since SQLite does not support row level locks, we have to acquire a reserved lock\n     * on the database immediately. Because of https://bugs.php.net/42766 we have to create\n     * such a transaction manually which also means we cannot use PDO::commit or\n     * PDO::rollback or PDO::inTransaction for SQLite.\n     *\n     * Also MySQLs default isolation, REPEATABLE READ, causes deadlock for different sessions\n     * due to https://percona.com/blog/2013/12/12/one-more-innodb-gap-lock-to-avoid/ .\n     * So we change it to READ COMMITTED.\n     */\n    private function beginTransaction(): void\n    {\n        if (!$this->inTransaction) {","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/symfony/http-foundation/blob/5aea19cd678fa4140f6108406f1096de5e9ed6e4/Session/Storage/Handler/PdoSessionHandler.php#L593-L629","documentation":"buildDsnFromUrl() recognizes only a fixed set of URL schemes (mapped to PDO drivers like mysql, pgsql, sqlsrv, sqlite, oci). A syntactically valid URL whose scheme is unknown reaches the default match arm and throws an InvalidArgumentException telling the user to pass a PDO DSN directly.","triggerScenarios":"Passing a URL with a scheme outside the alias map, e.g. 'mongodb://host/db', 'db2://...', or a typo like 'mysq://host' as the PdoSessionHandler DSN argument.","commonSituations":"Copy-pasting a URL from a different service (Redis, Mongo) into session storage config; typos in scheme names; using schemes like 'mssql://' which is aliased but 'sybase://' or custom schemes are not.","solutions":["Use a supported scheme: mysql, mysql2, postgres, pgsql, sqlite, mssql, sqlsrv, oci, oracle, or 'pdo-' prefixed variants","Fix typos in the scheme (e.g. mysq:// -> mysql://)","If your database has no supported URL scheme, pass a raw PDO DSN string instead (e.g. 'oci:dbname=//host/db')"],"exampleFix":"// before\n$handler = new \\PdoSessionHandler('mongodb://localhost/sessions');\n// after\n$handler = new \\PdoSessionHandler('mysql://user:pass@localhost/sessions');","handlingStrategy":"validation","validationCode":"$scheme = parse_url($url, PHP_URL_SCHEME);\n$supported = ['mysql','mysql2','postgres','pgsql','sqlite','mssql','sqlsrv','oci','oracle'];\nif (!in_array(preg_replace('/^pdo-/', '', (string) $scheme), $supported, true)) {\n    throw new \\InvalidArgumentException(sprintf('Unsupported session URL scheme \"%s\"; pass a PDO DSN instead.', $scheme));\n}","typeGuard":"function hasSupportedScheme(string $url): bool {\n    $map = ['mysql','mysql2','postgres','pgsql','sqlite','mssql','sqlsrv','oci','oracle'];\n    $s = preg_replace('/^pdo-/', '', (string) parse_url($url, PHP_URL_SCHEME));\n    return in_array($s, $map, true);\n}","tryCatchPattern":"try {\n    $handler = new \\PdoSessionHandler($url, $options);\n} catch (\\InvalidArgumentException $e) {\n    // unsupported scheme: switch to a supported scheme or a raw PDO DSN\n}","preventionTips":["Check the scheme against the supported list in docs before configuring session storage URL","Fix typos: mysq://, postgre:// are not recognized","For databases without a URL scheme, supply a native PDO DSN string instead"],"tags":["dsn","url-scheme","sessions","configuration"],"backgroundTag":"unsupported-enum-value","analyzedSha":"5aea19cd678fa4140f6108406f1096de5e9ed6e4","analyzedAt":"2026-09-13T01:52:22.855Z","contentChangedAt":"2026-09-13T01:52:22.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}