2017 © Pedro Peláez
 

library rdn-database

Zend Framework 2 database adapter manager

image

radnan/rdn-database

Zend Framework 2 database adapter manager

  • Saturday, December 28, 2013
  • by radnan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

RdnDatabase

The RdnDatabase ZF2 module provides a service locator for database adapters., (*1)

How to install

  1. Use composer to require the radnan/rdn-database package:, (*2)

    $ composer require radnan/rdn-database:1.*
    
  2. Activate the module by including it in your application.config.php file:, (*3)

    <?php
    
    return array(
       'modules' => array(
           'RdnDatabase',
           // ...
       ),
    );
    

How to use

Simply configure your database adapters with the RdnDatabase\Adapter\AdapterManager service locator using the rdn_db_adapters configuration option. Adapters are instances of the Zend\Db\Adapter\Adapter class., (*4)

<?php

return array(
    'rdn_db_adapters' => array(
        'invokables' => array(),
        'factories' => array(),
    ),
);

You can use the adapters key to dynamically create adapters using simple configuration:, (*5)

<?php

return array(
    'rdn_db_adapters' => array(
        'adapters' => array(
            'default' => array(
                'driver'   => 'pdo_mysql',
                'hostname' => null,
                'port'     => null,
                'username' => null,
                'password' => null,
                'database' => null,
            ),
        ),
    ),
);

The configuration options are used to create a Zend\Db\Adapter\Adapter object., (*6)

Controller Plugin

The module comes with the database() controller plugin that you can use to fetch database adapters from within a controller:, (*7)

class FooController
{
    public function indexAction()
    {
        /** @var \Zend\Db\Adapter\Adapter $adapter */
        $adapter = $this->database('default');
    }
}

Factories

The module depends on the RdnFactory module and provides a database() plugin you can use when creating factory classes., (*8)

namespace App\Factory\Controller;

use App\Controller;
use RdnFactory\AbstractFactory;

class Index extends AbstractFactory
{
    protected function create()
    {
        $adapter = $this->database('default');
        return new Controller\Index($adapter);
    }
}

The Versions

28/12 2013

dev-master

9999999-dev

Zend Framework 2 database adapter manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar radnan

database zf2 zend manager

28/12 2013

v1.0.0

1.0.0.0

Zend Framework 2 database adapter manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar radnan

database zf2 zend manager