antidot-fw / dbal-adapter
Doctrine DBAL adapter library for Antidot Framework.
Fund package maintenance!
kpicaza
Requires
- php: ^7.4|^8.0
- doctrine/dbal: ^2.10
- psr/container: ^1.0.0
Requires (Dev)
- phpro/grumphp: ^1.3.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.4
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2024-11-30 02:03:05 UTC
README
Doctrine DBAL adapter library for Antidot Framework.
Config
It uses the config parameters defined in the doctrine DBAL project docs.
<?php declare(strict_types=1); $config = [ 'dbal' => [ 'connections' => [ 'default' => [ 'url' => 'mysql://user:secret@localhost/mydb', ], 'other_connection' => [ 'dbname' => 'otherdb', 'user' => 'user', 'password' => 'secret', 'host' => 'localhost', 'driver' => 'pdo_mysql', ], ], ], ];
Usage
Using Laminas Component Installer
If your application uses PSR-11 container and Laminas Component installer it will work out of the box. only by installing it.
As standalone package
<?php declare(strict_types=1); use Antidot\Persistence\DBAL\Container\DBALConnectionFactory; use Psr\Container\ContainerInterface; /** @var ContainerInteface $container */ $container->set('config', $config); $factory = new DBALConnectionFactory(); $defaultConnection = $factory->__invoke($container); $theOtherConnection = $factory->__invoke($container, 'other_connection');