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
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
10 changes: 9 additions & 1 deletion console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,18 @@ 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.
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.


Executing the Command
---------------------

After configuring the command, you can execute it in the terminal:
After configuring and registering the command, you can execute it in the terminal:

.. code-block:: terminal

Expand Down