Skip to content

Instantly share code, notes, and snippets.

@jakzal
Last active August 29, 2015 14:04
Show Gist options
  • Save jakzal/3c225a526a292e8668f2 to your computer and use it in GitHub Desktop.
Save jakzal/3c225a526a292e8668f2 to your computer and use it in GitHub Desktop.
Dump a Symfony Standard Edition DI container
<?php
/**
* @license MIT
*/
$loader = require_once __DIR__.'/bootstrap.php.cache';
require_once __DIR__.'/AppKernel.php';
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\GraphvizDumper;
class DumperKernel extends \AppKernel
{
private $containerGraph;
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
{
$dumper = new GraphvizDumper($container);
$this->containerGraph = $dumper->dump(['graph' => ['rankdir' => 'RL']]);
parent::dumpContainer($cache, $container, $class, $baseClass);
}
public function dump()
{
$this->boot();
return $this->containerGraph;
}
}
$kernel = new DumperKernel('dev', true);
echo $kernel->dump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment