Skip to content

Instantly share code, notes, and snippets.

@davedevelopment
Created September 18, 2012 07:54
Show Gist options
  • Select an option

  • Save davedevelopment/3741881 to your computer and use it in GitHub Desktop.

Select an option

Save davedevelopment/3741881 to your computer and use it in GitHub Desktop.
Silex DI
/**
* The Application(which is an instance of Pimple) sets up it's required dependencies, one of which is a logger
*/
$this['logger'] = null;
/** snip */
/**
* The controller resolver takes an optional logger
*/
$this['resolver'] = $this->share(function () use ($app) {
return new ControllerResolver($app, $app['logger']);
});
/**
* Providers get passed the Application instance to register their services (and their dependencies)
*
* The Monolog provider adds it's own services to the container, and then overrides default logger
*/
$app['logger'] = function () use ($app) {
return $app['monolog'];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment