antidot-fw / dbal-adapter
Antidot 框架的 Doctrine DBAL 适配器库。
1.0.3
2021-01-10 15:16 UTC
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-08-30 01:34:16 UTC
README
Antidot 框架的 Doctrine DBAL 适配器库。
配置
它使用在Doctrine DBAL 项目文档中定义的配置参数。
<?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', ], ], ], ];
用法
使用 Laminas 组件安装程序
如果你的应用程序使用 PSR-11 容器以及 Laminas 组件安装程序,则无需额外操作即可正常工作,只需安装即可。
作为独立包
<?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');