Skip to content

Commit

Permalink
Merge pull request #222 from patchlevel/dsn-driver-mapping
Browse files Browse the repository at this point in the history
add dsn driver mapping
  • Loading branch information
DavidBadura authored Nov 25, 2024
2 parents ab1bf2e + 52ac735 commit 85d1c8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/pages/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ bin/console event-sourcing:subscription:setup

You can find out more about the cli in the [library](https://event-sourcing.patchlevel.io/latest/cli/).

### Usage
## Usage

We are now ready to use the Event Sourcing System. We can load, change and save aggregates.

Expand Down
19 changes: 18 additions & 1 deletion src/Doctrine/DbalConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,27 @@

final class DbalConnectionFactory
{
/**
* Mapping was taken from Doctrine Bundle.
*
* @see https://github.com/doctrine/DoctrineBundle/blob/7564fa72ab4a87316660347ccd226cefc8fb0ea9/src/ConnectionFactory.php#L35
*/
private const DEFAULT_SCHEME_MAP = [
'db2' => 'ibm_db2',
'mssql' => 'pdo_sqlsrv',
'mysql' => 'pdo_mysql',
'mysql2' => 'pdo_mysql', // Amazon RDS, for some weird reason
'postgres' => 'pdo_pgsql',
'postgresql' => 'pdo_pgsql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
'sqlite3' => 'pdo_sqlite',
];

public static function createConnection(string $url): Connection
{
return DriverManager::getConnection(
(new DsnParser())->parse($url),
(new DsnParser(self::DEFAULT_SCHEME_MAP))->parse($url),
);
}
}

0 comments on commit 85d1c8f

Please sign in to comment.