Skip to content

[FrameworkBundle] Add debug autoconfigure to the container debug command #26745

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
wants to merge 1 commit into from

Conversation

aaa2000
Copy link
Contributor

@aaa2000 aaa2000 commented Apr 2, 2018

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

This PR try to list the tags that are applied on certain classes through autoconfiguration

sf debug:container --autoconfigure
Symfony Container Autoconfiguring Tags
======================================

"console.command" tag
---------------------

 * Symfony\Component\Console\Command\Command

"config_cache.resource_checker" tag
-----------------------------------

 * Symfony\Component\Config\ResourceCheckerInterface

"container.env_var_processor" tag
---------------------------------

 * Symfony\Component\DependencyInjection\EnvVarProcessorInterface

"container.service_locator" tag
-------------------------------

 * Symfony\Component\DependencyInjection\ServiceLocator

@@ -121,6 +126,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$options = array();
} elseif ($parameter = $input->getOption('parameter')) {
$options = array('parameter' => $parameter);
} elseif ($input->getOption('autoconfigure')) {
@unlink($this->getApplication()->getKernel()->getContainer()->getParameter('debug.container.dump'));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The container dump doesn't contain the information concerning autoconfiguring tags. is it problematic? Is there another way? Should I pass an argument to getContainerBuilder to force a compilation ?

@linaori
Copy link
Contributor

linaori commented Apr 2, 2018

Wouldn't it make more sense to show the full template of the autoconfigure? Autoconfigure works based on an interface(/class?), thus it would make sense to see what other configuration is being added by this.

@aaa2000
Copy link
Contributor Author

aaa2000 commented Apr 3, 2018

Sorry, I don't understand. What is the the full template of the autoconfigure ? Do you propose to display like this:

    _instanceof:
        Symfony\Component\Security\Core\Authorization\Voter\VoterInterface:
            tags: [security.voter]

or do you propose to display like the output of the command php ./bin/console debug:container App\\Security\\PostVoter with the information of autoconfigure ?

Information for Service "App\Security\PostVoter"
================================================

 ---------------- ------------------------ 
  Option           Value                   
 ---------------- ------------------------ 
  Service ID       App\Security\PostVoter  
  Class            App\Security\PostVoter  
  Tags             security.voter          
  Public           no                      
  Synthetic        no                      
  Lazy             no                      
  Shared           yes                     
  Abstract         no                      
  Autowired        yes                     
  Autoconfigured   yes                     
  Autoconfigure class Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
  Autoconfigure tag security.voter
 ---------------- ------------------------ 

@linaori
Copy link
Contributor

linaori commented Apr 4, 2018

What about something like this?

Autoconfiguration for "Symfony\Component\Security\Core\Authorization\Voter\VoterInterface"
================================================

 ---------------- ------------------------ 
  Option           Value                   
 ---------------- ------------------------ 
  Tags             security.voter
  Public           no
  Any other options and values etc.
 ---------------- ------------------------ 

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Apr 4, 2018
@aaa2000
Copy link
Contributor Author

aaa2000 commented Apr 9, 2018

The command would have been useful to me during a migration of a project to the autowiring/autoconfigure.

Every time, I wondered if I could delete the configuration or not in services.yaml to reduce its size.

The command allows to know the autonconfiguring tags.
Which interface/class should be implemented to have autoconfiguration applied ?

If there is a need to know the full template, the command debug:container App\\Security\\PostVoter can be used. I have not yet meet the need to have the full template of the autoconfigure.

@nicolas-grekas
Copy link
Member

I really think such a command is a nice addition.
@iltar's comment is relevant especially now that autoconfiguration works for function calls (see #26768).

Maybe a separate command could be worth it? debug:autoconfiguration
by default it could display as @iltar suggests, and when the --tags is passed, be grouped by tags?

@nicolas-grekas nicolas-grekas modified the milestones: 4.1, next Apr 29, 2018
@nicolas-grekas
Copy link
Member

rebase needed (needs to account for the new show-hidden option)

@aaa2000
Copy link
Contributor Author

aaa2000 commented Oct 4, 2018

@nicolas-grekas I create the separate command in #28730

@chalasr
Copy link
Member

chalasr commented Oct 7, 2018

Closing in favor of #28730

@chalasr chalasr closed this Oct 7, 2018
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
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.

5 participants