Last active
August 1, 2020 06:19
-
-
Save sagikazarmark/4b52811c96e0fe6225022e038c7ccb9a to your computer and use it in GitHub Desktop.
Symfony container graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
use Symfony\Bundle\FrameworkBundle\Console\Application; | |
use Symfony\Component\Console\Input\ArgvInput; | |
use Symfony\Component\Debug\Debug; | |
// if you don't want to setup permissions the proper way, just uncomment the following PHP line | |
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information | |
//umask(0000); | |
set_time_limit(0); | |
/** | |
* @var Composer\Autoload\ClassLoader $loader | |
*/ | |
$loader = require __DIR__.'/../app/autoload.php'; | |
final class HacKernel extends AppKernel | |
{ | |
/** | |
* Recompiles the container without warming up the whole cache. | |
* | |
* Can be called upon docker container start to inject custom parameters. | |
*/ | |
public function exposeContainer() | |
{ | |
// Load class cache | |
if ($this->loadClassCache) { | |
$this->doLoadClassCache($this->loadClassCache[0], $this->loadClassCache[1]); | |
} | |
// Initialize bundles to be able to parse configurations | |
$this->initializeBundles(); | |
return $this->buildContainer(); | |
} | |
} | |
$input = new ArgvInput(); | |
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); | |
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod'; | |
if ($debug) { | |
Debug::enable(); | |
} | |
$kernel = new HacKernel($env, $debug); | |
$container = $kernel->exposeContainer(); | |
$container->compile(); | |
$graphDumper = new \Symfony\Component\DependencyInjection\Dumper\GraphvizDumper($container); | |
echo $graphDumper->dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment