ray/dbal-module

doctrine/dbal module for Ray.Di

1.1.0 2017-02-23 03:50 UTC

This package is auto-updated.

Last update: 2024-11-07 06:47:40 UTC


README

Scrutinizer Code Quality Code Coverage Build Status Build Status

Doctrine Dbal module for Ray.Di

Installation

Composer install

$ composer require ray/dbal-module

Module install

use BEAR\DbalModule\DbalModule;
use Ray\Di\AbstractModule;

class AppModule extends AbstractModule
{
    protected function configure()
    {
        $this->install(new DbalModule('driver=pdo_sqlite&memory=true');
    }
}

for named binding

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;
}

DI trait

  • DbalInject for Doctrine\DBAL\Driver\Connection interface

Demo

$ php docs/demo/run.php
// It works!