Doctrine Dbal module for Ray.Di
$ composer require ray/dbal-module
use BEAR\DbalModule\DbalModule;
use Ray\Di\AbstractModule;
class AppModule extends AbstractModule
{
protected function configure()
{
$this->install(new DbalModule('driver=pdo_sqlite&memory=true');
}
}
Set qualifer
in 2nd parameter in DbalModule.
$this->install(new DbalModule('driver=pdo_sqlite&memory=true', 'log_db');
Use qualifer in @Inject
.
/**
* @Inject
* @Named("log_db")
*/
public function setLogDb(Connection $logDb)
{
$this->logDb = $logDb;
}
- DbalInject for
Doctrine\DBAL\Driver\Connection
interface
$ php docs/demo/run.php
// It works!