Skip to content

Fix the explanation about registering commands #9419

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 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ method. Then you can optionally define a help message and the
Registering the Command
-----------------------

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.
Symfony commands must be registered before using them. In order to be registered
automatically, a command must be:

#. Stored in a directory called ``Command/``;
#. Defined in a class whose name ends with ``Command``;
#. Defined in a class that extends from
:class:`Symfony\\Component\\Console\\Command\\Command`.

If you can't meet these conditions for some command, the alternative is to
manually :doc`register the command as a service </console/commands_as_services>`.

Executing the Command
---------------------
Expand Down