-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added a caution note about invoking other commands #5425
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -476,6 +476,8 @@ method:: | |
You can also test a whole console application by using | ||
:class:`Symfony\\Component\\Console\\Tester\\ApplicationTester`. | ||
|
||
.. _calling-existing-command: | ||
|
||
Calling an Existing Command | ||
--------------------------- | ||
|
||
|
@@ -505,16 +507,26 @@ Calling a command from another one is straightforward:: | |
} | ||
|
||
First, you :method:`Symfony\\Component\\Console\\Application::find` the | ||
command you want to execute by passing the command name. | ||
|
||
Then, you need to create a new | ||
:class:`Symfony\\Component\\Console\\Input\\ArrayInput` with the arguments and | ||
options you want to pass to the command. | ||
command you want to execute by passing the command name. Then, you need to create | ||
a new :class:`Symfony\\Component\\Console\\Input\\ArrayInput` with the arguments | ||
and options you want to pass to the command. | ||
|
||
Eventually, calling the ``run()`` method actually executes the command and | ||
returns the returned code from the command (return value from command's | ||
``execute()`` method). | ||
|
||
.. tip:: | ||
|
||
If you want to suppress the output of the executed command, pass a :class:`Symfony\\Component\\Console\\Output\\NullOutput` | ||
as the second argument to ``$command->execute()``. | ||
|
||
.. caution:: | ||
|
||
Note that all the commands will run in the same process, and some of Symfony's | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the serial comma. ;) |
||
built-in commands may not work well this way. For instance, ``cache:clear`` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For instance, the [...] |
||
and ``cache:warmup`` commands change some class definitions, so running something | ||
after them is likely to break. | ||
|
||
.. note:: | ||
|
||
Most of the time, calling a command from code that is not executed on the | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,12 @@ before translating contents:: | |
However for other services the solution might be more complex. For more details, | ||
see :doc:`/cookbook/service_container/scopes`. | ||
|
||
Invoking Other Commands | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC "Other" should be lower-cased. |
||
----------------------- | ||
|
||
See :ref:`calling-existing-command` if you need to implement a command that runs | ||
other dependent commands. | ||
|
||
Testing Commands | ||
---------------- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
class
role should be moved to its own line.