symfony/http-foundation · error · DomainException

Creating the session table is currently not implemented for…

Error message

Creating the session table is currently not implemented for PDO driver "%s".

What it means

PdoSessionHandler::buildSchemaTable() builds the session table schema via a Dbal schema editor only for a known set of PDO drivers (mysql, sqlite, pgsql, oci, sqlsrv). When $this->driver falls outside that switch, a DomainException is thrown because column types/DDL differ per driver and no generic fallback exists.

Solutions

  1. Use a supported driver: mysql, sqlite, pgsql, oci, or sqlsrv in your PDO DSN
  2. If using an alias driver name, pass the URL form (database_url style) so buildDsnFromUrl normalizes aliases (mssql->sqlsrv, postgres->pgsql, mysql2->mysql)
  3. Normalize the driver name yourself before constructing the handler, or override/extend the handler to implement the schema for your driver

Example fix

// before
$pdo = new \PDO('odbc:DSN=mydb');
$handler = new \PdoSessionHandler($pdo);
// after
$pdo = new \PDO('mysql:host=localhost;dbname=mydb', $user, $pass);
$handler = new \PdoSessionHandler($pdo);
Defensive patterns

Strategy: validation

Validate before calling

$supported = ['mysql','sqlite','pgsql','oci','sqlsrv'];
if (!in_array($driverName, $supported, true)) {
    throw new \LogicException(sprintf('Driver "%s" unsupported by PdoSessionHandler; use one of: %s', $driverName, implode(',', $supported)));
}

Type guard

$driverName = (parse_url($url, PHP_URL_SCHEME) ?: substr($dsn, 0, strpos($dsn, ':')));
if (!is_string($driverName) || $driverName === '') { /* reject */ }

Prevention

When it happens

Trigger: Instantiating PdoSessionHandler with a PDO DSN whose driver name is not one of mysql/sqlite/pgsql/oci/sqlsrv (e.g. an unfamiliar or aliased driver string) while using the DBAL-based schema creation path (configureSchema -> buildSchemaTable).

Common situations: Using a driver name with different casing or an alias not normalized (e.g. 'mssql' instead of 'sqlsrv', 'postgres' instead of 'pgsql'), or a less common PDO driver like ibm/odbc with a DSN passed directly instead of a URL.

Related errors


AI-assisted analysis of symfony/http-foundation@5aea19cd67 (2026-09-13). Data as JSON: /api/errors/ae66bf0a18afd359. Report an issue: GitHub.

Appendix: source

Thrown at Session/Storage/Handler/PdoSessionHandler.php:249

                    ->addColumn(Column::editor()->setUnquotedName($this->lifetimeCol)->setTypeName(Types::INTEGER)->setNotNull(true)->create())
                    ->addColumn(Column::editor()->setUnquotedName($this->timeCol)->setTypeName(Types::INTEGER)->setNotNull(true)->create());
                break;
            case 'oci':
                $editor
                    ->addColumn(Column::editor()->setUnquotedName($this->idCol)->setTypeName(Types::STRING)->setLength(128)->setNotNull(true)->create())
                    ->addColumn(Column::editor()->setUnquotedName($this->dataCol)->setTypeName(Types::BLOB)->setNotNull(true)->create())
                    ->addColumn(Column::editor()->setUnquotedName($this->lifetimeCol)->setTypeName(Types::INTEGER)->setNotNull(true)->create())
                    ->addColumn(Column::editor()->setUnquotedName($this->timeCol)->setTypeName(Types::INTEGER)->setNotNull(true)->create());
                break;
            case 'sqlsrv':
                $editor
                    ->addColumn(Column::editor()->setUnquotedName($this->idCol)->setTypeName(Types::STRING)->setLength(128)->setNotNull(true)->create())
                    ->addColumn(Column::editor()->setUnquotedName($this->dataCol)->setTypeName(Types::BLOB)->setNotNull(true)->create())
                    ->addColumn(Column::editor()->setUnquotedName($this->lifetimeCol)->setTypeName(Types::INTEGER)->setUnsigned(true)->setNotNull(true)->create())
                    ->addColumn(Column::editor()->setUnquotedName($this->timeCol)->setTypeName(Types::INTEGER)->setUnsigned(true)->setNotNull(true)->create());
                break;
            default:
                throw new \DomainException(\sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver));
        }

        return $editor
            ->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted($this->idCol))], true))
            ->addIndex(Index::editor()->setUnquotedName($this->lifetimeCol.'_idx')->setUnquotedColumnNames($this->lifetimeCol)->create())
            ->create();
    }

    /**
     * To be removed when doctrine/dbal minimum is bumped to ^4.5.
     */
    private function configureSchemaTable(Table $table): void
    {
        switch ($this->driver) {
            case 'mysql':
                $table->addColumn($this->idCol, Types::BINARY, ['length' => 128, 'notnull' => true]);
                $table->addColumn($this->dataCol, Types::BLOB, ['notnull' => true]);
                $table->addColumn($this->lifetimeCol, Types::INTEGER, ['unsigned' => true, 'notnull' => true]);

View on GitHub (pinned to 5aea19cd67)