Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP][FrameworkBundle] Add debug autoconfigure command#28730

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@aaa2000
Copy link
Contributor

@aaa2000aaa2000 commentedOct 4, 2018
edited
Loading

Close#26295

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#26295
LicenseMIT
Doc PRsymfony/symfony-docs#...

Replace the pull request#26745.

Creation of a new command as proposed in the comment#26745 (comment) to show the full template of the autoconfigure of interfaces/classes

Output of the command based on modified symfony-demo application to have binding autoconfiguration, multiple tags attributes and multiple method calls
sf debug:autoconfiguration Autoconfiguration=================Autoconfiguration for "App\Twig\AppExtension"============================================== ---------- --------------------   Option     Value                ---------- --------------------   Tag        app.twig.extension    Bindings   $locales: fr|en|es                                    ---------- -------------------- Autoconfiguration for "Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface"============================================== -------- -----------------------------   Option   Value                         -------- -----------------------------   Tag      doctrine.repository_service   -------- ----------------------------- Autoconfiguration for "Doctrine\Bundle\FixturesBundle\ORMFixtureInterface"============================================== -------- ----------------------   Option   Value                  -------- ----------------------   Tag      doctrine.fixture.orm   -------- ---------------------- Autoconfiguration for "Psr\Log\LoggerAwareInterface"============================================== ------------- ----------------------------   Option        Value                        ------------- ----------------------------   Method call   - [setLogger, ['@logger']]                  - [setLogger, ['@logger']]                                               ------------- ---------------------------- Autoconfiguration for "Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface"============================================== -------- -------------------------   Option   Value                     -------- -------------------------   Tag      request.param_converter   -------- ------------------------- Autoconfiguration for "Symfony\Bridge\Monolog\Processor\ProcessorInterface"============================================== -------- -------------------   Option   Value               -------- -------------------   Tag      monolog.processor   -------- ------------------- Autoconfiguration for "Symfony\Bundle\FrameworkBundle\Controller\AbstractController"============================================== -------- ------------------------------   Option   Value                          -------- ------------------------------   Tag      controller.service_arguments   -------- ------------------------------ Autoconfiguration for "Symfony\Bundle\FrameworkBundle\Controller\Controller"============================================== -------- ------------------------------   Option   Value                          -------- ------------------------------   Tag      controller.service_arguments   -------- ------------------------------ Autoconfiguration for "Symfony\Component\Config\ResourceCheckerInterface"============================================== -------- -------------------------------   Option   Value                           -------- -------------------------------   Tag      config_cache.resource_checker   -------- ------------------------------- Autoconfiguration for "Symfony\Component\Console\Command\Command"============================================== -------- -----------------   Option   Value             -------- -----------------   Tag      console.command   -------- ----------------- Autoconfiguration for "Symfony\Component\DependencyInjection\EnvVarProcessorInterface"============================================== -------- -----------------------------   Option   Value                         -------- -----------------------------   Tag      container.env_var_processor   -------- ----------------------------- Autoconfiguration for "Symfony\Component\DependencyInjection\ServiceLocator"============================================== -------- ---------------------------   Option   Value                       -------- ---------------------------   Tag      container.service_locator   -------- --------------------------- Autoconfiguration for "Symfony\Component\EventDispatcher\EventSubscriberInterface"============================================== -------- -------------------------   Option   Value                     -------- -------------------------   Tag      kernel.event_subscriber   -------- ------------------------- Autoconfiguration for "Symfony\Component\Form\FormTypeGuesserInterface"============================================== -------- -------------------   Option   Value               -------- -------------------   Tag      form.type_guesser   -------- ------------------- Autoconfiguration for "Symfony\Component\Form\FormTypeInterface"============================================== -------- -----------   Option   Value       -------- -----------   Tag      form.type   -------- ----------- Autoconfiguration for "Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface"============================================== -------- ----------------------   Option   Value                  -------- ----------------------   Tag      kernel.cache_clearer   -------- ---------------------- Autoconfiguration for "Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface"============================================== -------- ---------------------   Option   Value                 -------- ---------------------   Tag      kernel.cache_warmer   -------- --------------------- Autoconfiguration for "Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface"============================================== -------- ------------------------------------   Option   Value                                -------- ------------------------------------   Tag      controller.argument_value_resolver   -------- ------------------------------------ Autoconfiguration for "Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface"============================================== -------- ----------------   Option   Value            -------- ----------------   Tag      data_collector   -------- ---------------- Autoconfiguration for "Symfony\Component\Messenger\Handler\MessageHandlerInterface"============================================== -------- ---------------------------   Option   Value                       -------- ---------------------------   Tag      messenger.message_handler   -------- --------------------------- Autoconfiguration for "Symfony\Component\Messenger\Transport\TransportFactoryInterface"============================================== -------- -----------------------------   Option   Value                         -------- -----------------------------   Tag      messenger.transport_factory   -------- ----------------------------- Autoconfiguration for "Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface"============================================== -------- --------------------------------   Option   Value                            -------- --------------------------------   Tag      property_info.access_extractor   -------- -------------------------------- Autoconfiguration for "Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface"============================================== -------- -------------------------------------   Option   Value                                 -------- -------------------------------------   Tag      property_info.description_extractor   -------- ------------------------------------- Autoconfiguration for "Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface"============================================== -------- ---------------------------------------   Option   Value                                   -------- ---------------------------------------   Tag      property_info.initializable_extractor   -------- --------------------------------------- Autoconfiguration for "Symfony\Component\PropertyInfo\PropertyListExtractorInterface"============================================== -------- ------------------------------   Option   Value                          -------- ------------------------------   Tag      property_info.list_extractor   -------- ------------------------------ Autoconfiguration for "Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface"============================================== -------- ------------------------------   Option   Value                          -------- ------------------------------   Tag      property_info.type_extractor   -------- ------------------------------ Autoconfiguration for "Symfony\Component\Security\Core\Authorization\Voter\VoterInterface"============================================== -------- ----------------   Option   Value            -------- ----------------   Tag      security.voter   -------- ---------------- Autoconfiguration for "Symfony\Component\Serializer\Encoder\DecoderInterface"============================================== -------- --------------------   Option   Value                -------- --------------------   Tag      serializer.encoder   -------- -------------------- Autoconfiguration for "Symfony\Component\Serializer\Encoder\EncoderInterface"============================================== -------- --------------------   Option   Value                -------- --------------------   Tag      serializer.encoder   -------- -------------------- Autoconfiguration for "Symfony\Component\Serializer\Normalizer\DenormalizerInterface"============================================== -------- -----------------------   Option   Value                   -------- -----------------------   Tag      serializer.normalizer   -------- ----------------------- Autoconfiguration for "Symfony\Component\Serializer\Normalizer\NormalizerInterface"============================================== -------- -----------------------   Option   Value                   -------- -----------------------   Tag      serializer.normalizer   -------- ----------------------- Autoconfiguration for "Symfony\Component\Validator\ConstraintValidatorInterface"============================================== -------- --------------------------------   Option   Value                            -------- --------------------------------   Tag      validator.constraint_validator   -------- -------------------------------- Autoconfiguration for "Symfony\Component\Validator\ObjectInitializerInterface"============================================== -------- -----------------------   Option   Value                   -------- -----------------------   Tag      validator.initializer   -------- ----------------------- Autoconfiguration for "Symfony\Contracts\Service\ResetInterface"============================================== --------------- --------------------------   Option          Value                      --------------- --------------------------   Tag             kernel.reset                Tag attribute   [                                             [                                             "method" => "reset"                       ]                                         ]                                                                       Tag             kernel.reset2               Tag attribute   [                                             [                                             "method" => "reset2"                      ]                                         ]                                                                      --------------- -------------------------- Autoconfiguration for "Symfony\Contracts\Service\ServiceSubscriberInterface"============================================== -------- ------------------------------   Option   Value                          -------- ------------------------------   Tag      container.service_subscriber   -------- ------------------------------ Autoconfiguration for "Twig\Extension\ExtensionInterface"============================================== -------- ----------------   Option   Value            -------- ----------------   Tag      twig.extension   -------- ---------------- Autoconfiguration for "Twig\Extension\RuntimeExtensionInterface"============================================== -------- --------------   Option   Value          -------- --------------   Tag      twig.runtime   -------- -------------- Autoconfiguration for "Twig\Loader\LoaderInterface"============================================== -------- -------------   Option   Value         -------- -------------   Tag      twig.loader   -------- ------------- Autoconfiguration for "Twig_ExtensionInterface"============================================== -------- ----------------   Option   Value            -------- ----------------   Tag      twig.extension   -------- ---------------- Autoconfiguration for "Twig_LoaderInterface"============================================== -------- -------------   Option   Value         -------- -------------   Tag      twig.loader   -------- -------------

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, here is a round of comments.

}
$tableRows[] = array('Public', $autoconfiguredInstanceofItem->isPublic() ? 'yes' : 'no');
$tableRows[] = array('Shared', $autoconfiguredInstanceofItem->isShared() ? 'yes' : 'no');
$tableRows[] = array('Autowired', $autoconfiguredInstanceofItem->isAutowired() ? 'yes' : 'no');

Choose a reason for hiding this comment

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

The only things that can be set by autoconfiguration are tags, method calls and bindings.
There is no need to list anything else.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I removed Public, Shared and Autowired and I add bindings

}

if ($tags && array_values($tags) !== array(array(array()))) {
$tableRows[] = array('Tags attributes', $this->dumpTagsAttributes($tags));

Choose a reason for hiding this comment

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

If there are any attributes, they should be listed next to their corresponding tags.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

If there are many attributes, the command displays like that

 --------------- --------------------------   Option          Value                      --------------- --------------------------   Tag             kernel.reset                Tag attribute   [                                             [                                             "method" => "reset"                       ]                                         ]                                                                       Tag             kernel.reset2               Tag attribute   [                                             [                                             "method" => "reset2"                      ]                                         ]                                                                      --------------- --------------------------

@nicolas-grekasnicolas-grekas added this to thenext milestoneOct 5, 2018
/** @var ChildDefinition $autoconfiguredInstanceofItem */
foreach ($autoconfiguredInstanceofItems as $key => $autoconfiguredInstanceofItem) {
$tags = $autoconfiguredInstanceofItem->getTags();
$tableRows = array();
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can get rid of the$tableRows array by usingaddRow() andrender(), as this is formaster. IMO its more readable afterwards

docs:https://symfony.com/doc/current/components/console/helpers/table.html#modifying-rendered-tables

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I'm not sure it's more readable. To have the same style that the others commands, it is necessary to configure the table.

diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutoconfigurationCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutoconfigurationCommand.phpindex bffdd32751..6d80649634 100644--- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutoconfigurationCommand.php+++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutoconfigurationCommand.php@@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command;  use Symfony\Component\Console\Command\Command;+use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption;Stash this hunk [y,n,q,a,d,j,J,g,/,e,?]? y@@ -91,26 +92,30 @@ EOF          /** @var ChildDefinition $autoconfiguredInstanceofItem */         foreach ($autoconfiguredInstanceofItems as $key => $autoconfiguredInstanceofItem) {-            $tableRows = array();+            $section = $output->section();+            $table = new Table($section);+            $table->setStyle(Table::getStyleDefinition('symfony-style-guide'));+            $table->addRow(array('Option', 'Value'));              foreach ($autoconfiguredInstanceofItem->getTags() as $tag => $tagAttributes) {-                $tableRows[] = array('Tag', $tag);+                $table->addRow(array('Tag', $tag));                 if ($tagAttributes !== array(array())) {-                    $tableRows[] = array('Tag attribute', $this->dumpTagAttribute($tagAttributes));+                    $table->addRow(array('Tag attribute', $this->dumpTagAttribute($tagAttributes)));                 }             }              if ($autoconfiguredInstanceofItem->getMethodCalls()) {-                $tableRows[] = array('Method call', $this->dumpMethodCall($autoconfiguredInstanceofItem));+                $table->addRow(array('Method call', $this->dumpMethodCall($autoconfiguredInstanceofItem)));             }              if ($autoconfiguredInstanceofItem->getBindings()) {-                $tableRows[] = array('Bindings', $this->dumpBindings($autoconfiguredInstanceofItem));+                $table->addRow(array('Bindings', $this->dumpBindings($autoconfiguredInstanceofItem)));             }              $io->writeln(sprintf("Autoconfiguration for \"%s\"\n==============================================", $key));             $io->newLine();-            $io->table(array('Option', 'Value'), $tableRows);+            $table->render();+            $io->newLine();         }     }

OskarStark reacted with thumbs up emoji
@OskarStark
Copy link
Contributor

OskarStark commentedOct 6, 2018
edited
Loading

Could you please post a screenshot of the output?

EDIT: Please add it to the PR header

@aaa2000aaa2000force-pushed thedebug-autoconfiguration-command branch from35a8f47 to09ea820CompareOctober 9, 2018 21:02
@aaa2000aaa2000 changed the title[FrameworkBundle] Add debug autoconfigure command[WIP][FrameworkBundle] Add debug autoconfigure commandOct 9, 2018
@aaa2000
Copy link
ContributorAuthor

@OskarStark Have you seen the output of command in the PR header, it requires to unfold. Do you prefer a screenshot ?

@@ -0,0 +1,9 @@
<?php

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\DebugAutoconfigurationBundle;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Maybe, I can use the TestBundle instead of create a new bundle ?

Fix many setMethodCalls displayFix autoconfiguration displayAdd bindings displayAdd tests with class fixtures
@aaa2000aaa2000force-pushed thedebug-autoconfiguration-command branch from4074a0d to00fb8aeCompareOctober 13, 2018 09:48
@OskarStark
Copy link
Contributor

Ah i missed it 😊

Copy link
Contributor

@ro0NLro0NL left a comment

Choose a reason for hiding this comment

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

not sure we need a new command, feels like it should be part ofdebug:container --autoconfiguration instead. Re-building and YAML dumping the container here looks suspicious to me.

Alternatively extend fromContainerDebugCommand likeDebugAutowiringCommand also does.

@aaa2000
Copy link
ContributorAuthor

Re-building and YAML dumping the container here looks suspicious to me.

Ok, I don't like it too but I didn't see other way to display method calls and bindings.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark left review comments

+1 more reviewer

@ro0NLro0NLro0NL left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

[RFC] [DI][Debug] Add command to debug autoconfigure tags

5 participants

@aaa2000@OskarStark@nicolas-grekas@ro0NL@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp