8000 [Console] Command Lifecycle explications by 94noni · Pull Request #5319 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Console] Command Lifecycle explications #5319

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 1 commit
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
Prev Previous commit
fix
  • Loading branch information
94noni committed Jun 2, 2015
commit 0faae4a8bad437c5411a6f0330d2a1fedb22a149
14 changes: 7 additions & 7 deletions components/console/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,24 @@ Command Lifecycle
Commands have three lifecycle methods:

:method:`Symfony\\Component\\Console\\Command\\Command::initialize`

This method is executed before the ``interact()`` and the ``execute()``
methods. It's main purpose is to initialize the variables used in the
rest of the command methods.

:method:`Symfony\\Component\\Console\\Command\\Command::interact`

This method is executed after ``initialize()`` and before ``execute()``.
Its purpose is to check if some of the options/arguments are missing
and interactively ask the user for those values.
and interactively ask the user for those values. This is the last place
where you can ask for missing options/arguments otherwise the command
Copy link
Member

Choose a reason for hiding this comment

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

I think we need a separation here:

[...] options/arguments otherwise [...]

[...] options/arguments. Otherwise [...]

will throw an error.

:method:`Symfony\\Component\\Console\\Command\\Command::execute`
This method is executed after ``interact()`` and ``initialize()``.
It contains the logic you want the command executes.
Copy link
Member

Choose a reason for hiding this comment

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

[...] the logic you want the command executes.

[...] the logic you want the command to execute.
(or)
[...] the logic you want to execute in the command.


This method is executed after ``interact()`` and ``initialize()``. It
usually contains the logic to execute to complete this command task.
Note that ``execute()`` is the only required method of the three.

Note that ``execute()`` is the only required method of the three. The
``initialize()`` and ``interact()`` methods are completely optional.
The ``initialize()`` and ``interact()`` methods are completely optional.
Copy link
Member

Choose a reason for hiding this comment

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

We can merge this phrase with the previous one.


.. _components-console-coloring:

Expand Down
0