You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand do not use the existing container generated by the kernel to find container extensions. This leads to an issue dumping config references for container extensions not loaded via an (old) bundle but via the kernel.
Example
I've added a container extension on my Kernel->build() function via...
protected function build(ContainerBuilder $container): void
{
$container->registerExtension(new MytestExtension());
}
Now i want to dump the configuration references via...
bin/console debug:config mytest
and
bin/console config:dump-reference mytest
but i get the error output
No extensions with configuration available for "mytest".
After some debugging i found out, that Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand uses a findExtension() function from Symfony\Bundle\FrameworkBundle\Command\AbstractConfigCommand which loads available container extensions just for bundles in the initializeBundles() function.
Questions
Wouldn't it be possible to easily use the existing container (which includes my extension) build by the kernel inside of AbstractConfigCommand so my kernel don't have to implement those interfaces ?
...or at least add the kernel->build() call to the initializeBundles() function ?
The text was updated successfully, but these errors were encountered:
simonchrz
changed the title
[FrameworkBundle]
[FrameworkBundle] ConfigDumpReferenceCommand is not recognizing container extensions loaded via kernel
Sep 19, 2022
…bug mode (HypeMC)
This PR was merged into the 5.4 branch.
Discussion
----------
[FrameworkBundle] Fix `debug:config` & `config:dump` in debug mode
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#47623
| License | MIT
| Doc PR | -
Displaying configs for extensions without a bundle using the `debug:config` & `config:dump-reference` commands works depending on whether debug is `true` or `false`. The reason behind this is the following code:
https://github.com/symfony/symfony/blob/b4128fdefea4ff95b27861bf65ba789d24868df1/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php#L42-L60
When debug is `true` the extensions are never loaded in the container, so the commands don't work.
There are even tests for these cases but they are all executed with debug `false`.
This PR aims to make the commands work with both debug `true` & `false`. Another problem is that these extensions are not visible in the list of available extensions and are not offered by the completion feature, but since those seem more like new features I've created a separate PR for 6.4: #50548
Commits
-------
2824fc5 [FrameworkBundle] Fix `debug:config` & `config:dump` in debug mode
Description
Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand do not use the existing container generated by the kernel to find container extensions. This leads to an issue dumping config references for container extensions not loaded via an (old) bundle but via the kernel.
Example
I've added a container extension on my Kernel->build() function via...
Now i want to dump the configuration references via...
but i get the error output
After some debugging i found out, that Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand uses a findExtension() function from Symfony\Bundle\FrameworkBundle\Command\AbstractConfigCommand which loads available container extensions just for bundles in the initializeBundles() function.
Some steps back i found out, that i have to implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface and Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface on my Kernel so my extension is loaded directly via my Kernel->getConfiguration() function.
Questions
Wouldn't it be possible to easily use the existing container (which includes my extension) build by the kernel inside of AbstractConfigCommand so my kernel don't have to implement those interfaces ?
...or at least add the kernel->build() call to the initializeBundles() function ?
The text was updated successfully, but these errors were encountered: