它是来自symfony文档Compiling the Container
的编译容器public static function create($filename, $isDebug = false)
{
$containerConfigCache = new ConfigCache($filename, $isDebug);
if (!$containerConfigCache->isFresh()) {
$containerBuilder = new ContainerBuilder();
$extension = new NfqParkingExtension();
$containerBuilder->registerExtension($extension);
$containerBuilder->loadFromExtension($extension->getAlias());
$containerBuilder->compile();
$dumper = new PhpDumper($containerBuilder);
$containerConfigCache->write(
$dumper->dump(['class' => 'testContainer']),
$containerBuilder->getResources()
);
}
require_once $filename;
return new testContainer();
}