Set up the CycleORM DBAL

This commit is contained in:
Dave Smith-Hayes 2025-06-18 21:45:59 -04:00
parent 6742ffa671
commit 13aa57512d
2 changed files with 253 additions and 210 deletions

433
app/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,9 @@ use Odan\Session\PhpSession;
use Odan\Session\SessionInterface; use Odan\Session\SessionInterface;
use Odan\Session\SessionManagerInterface; use Odan\Session\SessionManagerInterface;
use Cycle\Database as CycleDatabase;
use Cycle\Database\Config as CycleConfig;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
@ -175,6 +178,33 @@ class Bootstrap
); );
}, },
'dbal' => function (ContainerInterface $container) {
$config = $container->get('config');
$tcpConnectionConfig = new CycleConfig\MySQL\TcpConnectionConfig(
database: $config->get('database.database'),
host: $config->get('database.host'),
user: $config->get('database.username'),
password: $config->get('database.password'),
port: 3306
);
$driverConfig = new CycleConfig\MySQLDriverConfig(
connection: $tcpConnectionConfig,
queryCache: true
);
return new CycleDatabase\DatabaseManager(
new CycleConfig\DatabaseConfig([
'default' => 'default',
'databases' => [
'default' => [ 'connection' => 'mysql' ]
],
'connections' => [ 'mysql' => $driverConfig ],
])
);
},
/** /**
* FlySystem set up * FlySystem set up
*/ */