Skip to content

Added a short section about registering commands #9408

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 2 commits into from

Conversation

javiereguiluz
Copy link
Member

After merging #9403, I realized that we could add a short section explaining that commands must be registered (although Symfony does this for you most of the times). If we merge this, in 3.4 I'll change the description to mention the autoconfiguration instead of this, which is what #9403 fixed.

Symfony commands must be registered as services and :doc:`tagged </service_container/tags>`
with the ``console.command`` tag. If the PHP class of your command extends from
:class:`Symfony\\Component\\Console\\Command\\Command`, Symfony does this for
you automatically.
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look right to me. Commands do not need to be registered as services in Symfony 2.7 as they are auto-discovered. Additionally, these will not be tagged automatically by Symfony (autoconfiguration was added in 3.3).

Copy link
Member Author

Choose a reason for hiding this comment

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

So, the conditions in 2.7 and 2.8 are: the command must be stored in Command/ dir, the class name must end in Command and they must extend the base Command class?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, and IIRC correctly we have a section somewhere in the docs that explains these steps.

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.

3 participants