Skip to content

Instantly share code, notes, and snippets.

@prolic
Created April 27, 2012 13:06
Show Gist options
  • Save prolic/2509032 to your computer and use it in GitHub Desktop.
Save prolic/2509032 to your computer and use it in GitHub Desktop.
Generate a service locator when in development mode
$config; // array with di configuration
if (APPLICATION_ENV == 'development' || !class_exists('Application\Context') {
$di = new Zend\Di\Di($config);
$generator = new Generator($di);
$generator->setNamespace('Application')
->setContainerClass('Context');
$file = $generator->getCodeGenerator();
$file->setFilename(__DIR__ . '/../Application/Context.php');
$file->write();
}
$context = new Appliation\Context;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment