Skip to content

Instantly share code, notes, and snippets.

@mheap
Created May 22, 2014 10:42
Show Gist options
  • Save mheap/334add73b5c059240817 to your computer and use it in GitHub Desktop.
Save mheap/334add73b5c059240817 to your computer and use it in GitHub Desktop.
# Install it
Add to composer:
"symfony/dependency-injection": "2.4.2",
"symfony/yaml": "2.4.2",
# Configure it
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
$loader->load('/path/to/definition.yml);
return $container;
?>
# Use it
<?php $db = $container->get("db"); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment