Skip to content

Instantly share code, notes, and snippets.

@sylarbg
Forked from Ocramius/module.config.php
Created November 21, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sylarbg/fac237252dced770cdbf to your computer and use it in GitHub Desktop.
Save sylarbg/fac237252dced770cdbf to your computer and use it in GitHub Desktop.
Zend\Db adapter instantiation through Zend Framework 2 Di
<?php
return array(
'di' => array(
'definition' => array(
//teaching DI to use the factory
'class' => array(
'Zend\Db\Db' => array(
'methods' => array(
'factory' => array(
'adapter' => array(
'type' => false,
'required' => true,
),
'config' => array(
'type' => false,
'required' => false,
),
),
),
),
'Zend\Db\Adapter\AbstractAdapter' => array(
'instantiator' => array(
'Zend\Db\Db',
'factory',
),
),
),
),
'instance' => array(
'alias' => array(
//we just know it's an abstract adapter
'my-db-adapter' => 'Zend\Db\Adapter\AbstractAdapter',
),
//documentmanager
'my-db-adapter' => array(
'parameters' => array(
'adapter' => array(
// same db factory parameters you used in 1.x (I suppose)
),
),
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment