Array ( [Container%s/getFooService.php] => services['foo'] = new \FooClass\Foo(); } } [Container%s/ProjectServiceContainer.php] => ['symfony/test', '6.3', 'The parameter "%s" is deprecated.', 'foo_class'], ]; protected $targetDir; protected $parameters = []; public function __construct(private array $buildParameters = [], protected string $containerDir = __DIR__) { $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; $this->fileMap = [ 'foo' => 'getFooService', ]; $this->aliases = []; } public function compile(): void { throw new LogicException('You cannot compile a dumped container that was already compiled.'); } public function isCompiled(): bool { return true; } protected function load($file, $lazyLoad = true): mixed { if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) { return $class::do($this, $lazyLoad); } if ('.' === $file[-4]) { $class = substr($class, 0, -4); } else { $file .= '.php'; } $service = require $this->containerDir.\DIRECTORY_SEPARATOR.$file; return class_exists($class, false) ? $class::do($this, $lazyLoad) : $service; } public function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null { if (isset(self::DEPRECATED_PARAMETERS[$name])) { trigger_deprecation(...self::DEPRECATED_PARAMETERS[$name]); } if (isset($this->buildParameters[$name])) { return $this->buildParameters[$name]; } if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) { throw new ParameterNotFoundException($name); } if (isset($this->loadedDynamicParameters[$name])) { return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name); } return $this->parameters[$name]; } public function hasParameter(string $name): bool { if (isset($this->buildParameters[$name])) { return true; } return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters); } public function setParameter(string $name, $value): void { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } public function getParameterBag(): ParameterBagInterface { if (null === $this->parameterBag) { $parameters = $this->parameters; foreach ($this->loadedDynamicParameters as $name => $loaded) { $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name); } foreach ($this->buildParameters as $name => $value) { $parameters[$name] = $value; } $this->parameterBag = new FrozenParameterBag($parameters, self::DEPRECATED_PARAMETERS); } return $this->parameterBag; } private $loadedDynamicParameters = []; private $dynamicParameters = []; private function getDynamicParameter(string $name) { throw new ParameterNotFoundException($name); } protected function getDefaultParameters(): array { return [ 'foo_class' => 'FooClass\\Foo', ]; } } [ProjectServiceContainer.preload.php] => = 7.4 when preloading is desired use Symfony\Component\DependencyInjection\Dumper\Preloader; if (in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) { return; } require dirname(__DIR__, %d)%svendor/autoload.php'; (require __DIR__.'/ProjectServiceContainer.php')->set(\Container%s\ProjectServiceContainer::class, null); require __DIR__.'/Container%s/getFooService.php'; $classes = []; $classes[] = 'FooClass\Foo'; $classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface'; $preloaded = Preloader::preload($classes); [ProjectServiceContainer.php] => '%s', 'container.build_id' => '%s', 'container.build_time' => %d, ], __DIR__.\DIRECTORY_SEPARATOR.'Container%s'); )