Skip to content

[FrameworkBundle] ConfigDumpReferenceCommand is not recognizing container extensions loaded via kernel #47623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simonchrz opened this issue Sep 19, 2022 · 1 comment

Comments

@simonchrz
Copy link
Contributor

simonchrz commented Sep 19, 2022

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...

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.

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 ?

@simonchrz simonchrz changed the title [FrameworkBundle] [FrameworkBundle] ConfigDumpReferenceCommand is not recognizing container extensions loaded via kernel Sep 19, 2022
@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

nicolas-grekas added a commit that referenced this issue Jun 8, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants