Skip to content

[FrameworkBundle] Add debug:autoconfigure command #31183

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

Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Apr 19, 2019

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #26295
License MIT
Doc PR todo

SEE for a complete output and more insight #28730

As far as I'm concerned, i've seen @ro0NL's comments on the PR, I think this is ready and working, we can tweak it, but letting the work from @aaa2000 being dead it not the right call IMHO. This is the the raw commit rebased with master and pushed.

@Simperfit Simperfit changed the title Add debug autoconfigure command [FrameworkBundle] Add debug autoconfigure command Apr 19, 2019
@nicolas-grekas nicolas-grekas added this to the next milestone Apr 19, 2019
@OskarStark
Copy link
Contributor

Please use short array syntax 😊

@Simperfit Simperfit force-pushed the feature/add-debug-autoconfigue-command branch from 4057f66 to f2dec47 Compare April 21, 2019 07:25
@Simperfit Simperfit marked this pull request as ready for review April 21, 2019 07:42
@Simperfit Simperfit force-pushed the feature/add-debug-autoconfigue-command branch 2 times, most recently from d81ee6c to 4d7e67f Compare April 21, 2019 15:03
@Simperfit
Copy link
Contributor Author

cc @chalasr

@Simperfit
Copy link
Contributor Author

AppVeyor failure seems not related

@Simperfit
Copy link
Contributor Author

cc @ro0NL @chalasr what can we do about this ? Do we refator the whole thing or just let this work die ?

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im still 👍 for debug:autoconfiguration

/**
* @return ContainerBuilder
*/
private function getContainerBuilder()
Copy link
Contributor

@ro0NL ro0NL Jul 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the version from ContainerDebugCommand::getContainerBuilder() blocking for this implementation? extending from ContainerDebugCommand gives us things for free

{
$tagContainerBuilder = new ContainerBuilder();
foreach ($tagContainerBuilder->getServiceIds() as $serviceId) {
$tagContainerBuilder->removeDefinition($serviceId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt $tagContainerBuilder empty already 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's to make sure. And we could refactor it to be save empty and clone it on each call, no ?

$tagContainerBuilder->addDefinitions([$autoconfiguredInstanceofItem]);

$dumper = new YamlDumper($tagContainerBuilder);
preg_match('/calls\:\n((?: +- .+\n)+)/', $dumper->dump(), $matches);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no big fan of this approach, i'd opt for passing e.g. getMethodCalls() and render plain text as needed. Eventually could be inlined in execute()

private function dumpTagAttribute(array $tagAttribute)
{
$cloner = new VarCloner();
$cliDumper = new CliDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#28898 is meant for this :)

Copy link
Contributor

@maxhelias maxhelias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if this kind of command existed, now i have the answer.

I'm totally 👍 for this feature.

I have some question

{
$tagContainerBuilder = new ContainerBuilder();
foreach ($tagContainerBuilder->getServiceIds() as $serviceId) {
$tagContainerBuilder->removeDefinition($serviceId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's to make sure. And we could refactor it to be save empty and clone it on each call, no ?

@@ -376,7 +376,9 @@ public function load(array $configs, ContainerBuilder $container)
$container->registerForAutoconfiguration(LocaleAwareInterface::class)
->addTag('kernel.locale_aware');
$container->registerForAutoconfiguration(ResetInterface::class)
->addTag('kernel.reset', ['method' => 'reset']);
->addTag('kernel.reset', ['method' => 'reset'])
->addTag('kernel.reset2', ['method' => 'reset2'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not it be a forgotten ? It seems strange to me

@Simperfit
Copy link
Contributor Author

will try to fix this tomorrow.

@maxhelias
Copy link
Contributor

Or maybe we can do like for #32584, add a option like --auto ?

@nicolas-grekas nicolas-grekas changed the base branch from master to 4.4 September 29, 2019 11:31
@nicolas-grekas nicolas-grekas changed the title [FrameworkBundle] Add debug autoconfigure command [FrameworkBundle] Add debug:autoconfigure command Sep 29, 2019
@nicolas-grekas nicolas-grekas force-pushed the feature/add-debug-autoconfigue-command branch from 4d7e67f to 09bb892 Compare September 29, 2019 12:04
@nicolas-grekas
Copy link
Member

I checked out the PR and here are two things that should be improved to me:

  • the output should be way more compact
  • the getContainerBuilder() method in the command always compiles the container. Since this is a slow process, we'd better read from the dumped XML container (then, the command could extend from ContainerDebugCommand as does DebugAutowiringCommand btw). This means we first need to dump autoconfigured types in the XML since they're not right now.

@Simperfit still available to work on this? Otherwise don't hesitate to call for help.

@Simperfit
Copy link
Contributor Author

@nicolas-grekas Thanks for the review, ill look into it this week.

@nicolas-grekas
Copy link
Member

Anyone willing to take over this one?

@atailouloute
Copy link
Contributor

@nicolas-grekas I can take over this if no one did.

@nicolas-grekas
Copy link
Member

Sure, please do!

@atailouloute
Copy link
Contributor

Should I create a new PR starting from this branch ? I don't think I have write access to Simperfit's repo

@nicolas-grekas
Copy link
Member

Please create another PR.

@chalasr
Copy link
Member

chalasr commented Dec 18, 2019

Closing in favor of #35033.

@chalasr chalasr closed this Dec 18, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants