Skip to content

PHP-DI integration with Zend Framework 2

License

Notifications You must be signed in to change notification settings

koubas/PHP-DI-ZF2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP-DI integration with Zend Framework 2

This library provides integration for PHP-DI with Zend Framework 2.

PHP-DI is a Dependency Injection Container for PHP.

If you are looking for Zend Framework 1 integration, head over here.

Use

Require the libraries with Composer:

{
    "require": {
        "mnapoli/php-di": "*",
        "mnapoli/php-di-zf2": "*"
    }
}

To use PHP-DI in your ZF2 application, you need to edit application_root/module/Application/config/module.config.php:

    // ...
    'modules' => array(
        'DI\ZendFramework2',
    ),
    // ...
    'service_manager' => array(
        // ...
        'factories' => array(
            'DI\Container' => function () {
                $builder = new DI\ContainerBuilder();
                // Configure your container here
                return $builder->build();
            },
        ),
    ),

That's it!

Now you dependencies are injected in your controllers!

Head over to PHP-DI's documentation if needed.

About

PHP-DI integration with Zend Framework 2

Resources

License

Stars

Watchers

Forks

Packages

No packages published