Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Zend\Di compiler utility module to make ZF2 applications blazing fast
branch: master
Failed to load latest commit information.
.travis Fixing Travis-CI reserved files locations
src/OcraDiCompiler Duplicating some ZF2 factories to avoid instantiation of Di or the Di…
tests Refactoring structure of the module to consume compiled arrays of clo…
.travis.yml Removing Di initializer since it isn't fixable right now. Fixing trav…
LICENSE Importing project code
Module.php Importing project code Refactoring structure of the module to consume compiled arrays of clo…
composer.json Making autoloading depend on composer only


A compiler module to make Zend\Di\Di based applications blazing fast!



  1. Add "ocramius/ocra-di-compiler": "dev-master" to your composer.json
  2. Run php composer.phar install
  3. Enable the module in your config/application.config.php by adding OcraDiCompiler to modules


OcraDiCompiler interacts with the bootstrap process of your application by trying to write a compiled Zend\Di\Di class into your data directory. The compiled Di container will be available after the bootstrap event of your application. Before that, any attempt to access Di will fetch the default one. You can customize where the compiled Di class will be written (and from where it will be read) by overriding the values in config/module.config.php in your own config file in the config/autoload directory.

Performance comparison

Given a default setup of an application with doctrine/DoctrineORMModule enabled and following class:

class MyClass
    public function __construct(\Doctrine\ORM\EntityManager $em)

following code


should be noticeably faster (please leave me your feedback and your personal results!).


Many thanks to Sascha Oliver Prolic, who wrote the implementation of the DiProxyGenerator and patiently waited for me to get this module implemented

Something went wrong with that request. Please try again.