Skip to content

Instantly share code, notes, and snippets.

@blockjon
Created February 11, 2014 23:00
Show Gist options
  • Save blockjon/8946114 to your computer and use it in GitHub Desktop.
Save blockjon/8946114 to your computer and use it in GitHub Desktop.
This is how I'm trying to create a lazy loaded service.
$rollbarServiceDefinition = new \Symfony\Component\DependencyInjection\Definition('\RollbarNotifier');
$rollbarServiceDefinition->addArgument($config['rollbarnotifier']);
$rollbarServiceDefinition->setLazy(true);
$container->setDefinition('foo.service.rollbarnotifier', $rollbarServiceDefinition);
... later on when I do a $container->get('foo.service.rollbarnotifier'), I see it invoking my __construct() function of \RollbarNotifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment