A Doctrine Dbal module for Ray.Di
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs/demo
src
tests
.gitignore
.php_cs
.php_cs.cache
.scrutinizer.yml
.travis.yml
LICENSE
README.md
composer.json
phpcs.xml
phpmd.xml
phpunit.xml.dist

README.md

Ray.DbalModule

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!