File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,26 @@ shown in these three formats.
65
65
Starting from Symfony 5.1, by default Symfony only loads the configuration
66
66
files defined in YAML format. If you define configuration in XML and/or PHP
67
67
formats, update the ``src/Kernel.php `` file to add support for the ``.xml ``
68
- and ``.php `` file extensions.
68
+ and ``.php `` file extensions by overriding the
69
+ :method: `Symfony\\ Component\\ HttpKernel\\ Kernel::configureContainer ` method::
70
+
71
+ // src/Kernel.php
72
+ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
73
+
74
+ private function configureContainer(ContainerConfigurator $container): void
75
+ {
76
+ $configDir = $this->getConfigDir();
77
+
78
+ $container->import($configDir.'/{packages}/*.{yaml,php}');
79
+ $container->import($configDir.'/{packages}/'.$this->environment.'/*.{yaml,php}');
80
+
81
+ if (is_file($configDir.'/services.yaml')) {
82
+ $container->import($configDir.'/services.yaml');
83
+ $container->import($configDir.'/{services}_'.$this->environment.'.yaml');
84
+ } else {
85
+ $container->import($configDir.'/{services}.php');
86
+ }
87
+ }
69
88
70
89
There isn't any practical difference between formats. In fact, Symfony
71
90
transforms and caches all of them into PHP before running the application, so
You can’t perform that action at this time.
0 commit comments