-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DX][FrameworkBundle] Show private aliases in debug:container #22385
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
Conversation
d5615bf
to
d18ba64
Compare
4581894
to
7d744e0
Compare
Change documented and functionally tested. |
374f779
to
a065014
Compare
I can't imagine any existing feature impacted by this change. Also, the fixed ticket is 2 years old and it seems everyone agree this would be useful, it makes things simpler. That said , I would love to get this in 3.3. |
Added some screenshots to the PR body. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't review this proposal technically, but from the DX point of view is perfect! Thanks @chalasr.
throw new \LogicException('Debug information about the container is only available in debug mode.'); | ||
} | ||
|
||
if (!is_file($cachedFile = $this->getContainer()->getParameter('debug.container.dump'))) { | ||
throw new \LogicException('Debug information about the container could not be found. Please clear the cache and try again.'); | ||
if (is_file($cachedFile = $this->getContainer()->getParameter('debug.container.dump'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, debug.container.dump
was only added by the compiler pass you deprecated. So this looks suspicious to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter isn't added by the pass, but loaded from there https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml#L8. Do you think it's time to remove it?
if (!$this->getApplication()->getKernel()->isDebug()) { | ||
$kernel = $this->getApplication()->getKernel(); | ||
|
||
if (!$kernel->isDebug()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we actually need to keep this restriction ? Previously, it was because you the compiler pass was only dumping the file in debug mode. But you don't rely on this file anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're sure there is nothing wrong to get these informations available in non debug mode, I would be glad to remove this check.
$container->compile(); | ||
$filesystem = new Filesystem(); | ||
try { | ||
$filesystem->dumpFile($cachedFile, (new XmlDumper($container))->dump()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why dumping it ? If the goal is to use a cache to make next calls to the command faster, you must use the ConfigCache component to invalidate the cache when the container changes. Otherwise, the command will give outdated data once you edit the container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is indeed to make the next call faster, as it is currently. About invalidation, it seems to work naturally when clearing the cache, maybe due to the fact this dump is named %kernel.cache_dir%/%kernel.container_class%.xml
? Not sure if it's worth dumping it at all, I think it's relevant to don't need to clear the cache for getting debug informations. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except that in dev, I never clear the cache fuly (except when running a composer command doing it for me), as cache files are refreshed individually when needed in debug mode (which is the main feature of the debug mode)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to use config cache, removed the debug.container.dump
parameter also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter removal and compiler pass deprecation reverted, it now leverages the debug mode properly which isn't the case currently. It would be great if you could have a look
43d9aae
to
badb0dc
Compare
$container = $buildContainer(); | ||
$container->getCompilerPassConfig()->setRemovingPasses(array()); | ||
$container->compile(); | ||
$cache->write((new XmlDumper($container))->dump(), array(new FileResource($cacheDir.'/'.$containerClass.'.php'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should rather register the ContainerBuilder resources here rather than a FileResource for the compiled container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
57596c0
to
84b1a47
Compare
I may have read too quickly, but doesn't this remove an XML file that maybe of use to some tier tools? Eg the phpstorm SF plugin and the likes? |
1cad653
to
57db321
Compare
@nicolas-grekas You're right, the phpstorm plugin relies on. |
PhpStorm Plugin point of view. as i see this PR just extends the xml files, so i am able to resolve Haehnchen/idea-php-symfony2-plugin#618 on my side |
8dde8ae
to
5810d77
Compare
👍 |
c0d418d
to
051b200
Compare
ping @symfony/deciders |
051b200
to
6746c06
Compare
6746c06
to
883723e
Compare
PR rebased. |
👍 (and 👍 for 3.3 for me, it's really a bug fix) |
I think we are good here. |
Can we reconsider the milestone here? A lot of services can be made private in 3.3, it would be too bad to miss them. |
I also think we should reconsider this a bug fix for 3.3. "Types" are much more important in 3.3... but there's no way to get a list of them. And currently we can't even use When I run Would it be possible to bump this to 3.3 as a bug fix? |
Thank you @chalasr. |
…ntainer (chalasr) This PR was merged into the 3.3-dev branch. Discussion ---------- [DX][FrameworkBundle] Show private aliases in debug:container | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16388 Haehnchen/idea-php-symfony2-plugin#618 | License | MIT | Doc PR | n/a By building and compiling the container without `TYPE_REMOVING` passes, private aliases are available (shown when `--show-private` is passed). The ContainerBuilderDebugDumpPass now makes use of the ConfigCache component, removing the need for clearing the cache to get the debug:container output up to date (in sync with latest config). Config ------- ```yaml services: AppBundle\Foo: public: false foo_consumer1: class: AppBundle\Foo arguments: [ '@appbundle\Foo' ] foo_consumer2: class: AppBundle\Foo arguments: [ '@appbundle\Foo' ] foo_alias: alias: AppBundle\Foo foo_private_alias: public: false alias: AppBundle\Foo ``` Before -------  After ------  Commits ------- 883723e Show private aliases in debug:container
This PR was squashed before being merged into the 3.3-dev branch (closes #22624). Discussion ---------- debug:container --types (classes/interfaces) | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none, but needed in symfony/symfony-docs#7807 | License | MIT | Doc PR | n/a In Symfony 3.3, the *type* (i.e. class/interface) is the most important thing about a service. But, we don't have a way for the user to know *what* types are available. This builds on top of `debug:container` to make `debug:container --types`: <img width="1272" alt="screen shot 2017-05-03 at 3 42 37 pm" src="https://cloud.githubusercontent.com/assets/121003/25678671/8bebacaa-3018-11e7-9cf6-b7654e2cae88.png"> I think we need this for 3.3, so I've made the diff as *small* as possible. We could make improvements for 3.4, but just *having* this is the most important. I could even remove `format` support to make the diff smaller. ~~This depends on #22385, which fixes a "bug" where private services aren't really shown.~~ Thanks! Commits ------- 25a39c2 debug:container --types (classes/interfaces)
By building and compiling the container without
TYPE_REMOVING
passes, private aliases are available (shown when--show-private
is passed). The ContainerBuilderDebugDumpPass now makes use of the ConfigCache component, removing the need for clearing the cache to get the debug:container output up to date (in sync with latest config).Config
Before
After