Skip to content

Commit

Permalink
Move Command Lifecycle to guide
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Jul 15, 2016
1 parent cbca1c0 commit 038a045
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
23 changes: 0 additions & 23 deletions components/console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,6 @@ This prints::

HELLO FABIEN

Command Lifecycle
~~~~~~~~~~~~~~~~~

Commands have three lifecycle methods:

:method:`Symfony\\Component\\Console\\Command\\Command::initialize` *(optional)*
This method is executed before the ``interact()`` and the ``execute()``
methods. Its main purpose is to initialize variables used in the rest of
the command methods.

:method:`Symfony\\Component\\Console\\Command\\Command::interact` *(optional)*
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. This is the last place
where you can ask for missing options/arguments. After this command,
missing options/arguments will result in an error.

:method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)*
This method is executed after ``interact()`` and ``initialize()``.
It contains the logic you want the command to execute.



Console Helpers
---------------

Expand Down
22 changes: 22 additions & 0 deletions console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,28 @@ Now, once you created the required services and logic, the command will execute
the ``generate()`` method of the ``app.admin_generator`` service and the admin
will be created.
Command Lifecycle
~~~~~~~~~~~~~~~~~
Commands have three lifecycle methods that are invoked when running the
command:
:method:`Symfony\\Component\\Console\\Command\\Command::initialize` *(optional)*
This method is executed before the ``interact()`` and the ``execute()``
methods. Its main purpose is to initialize variables used in the rest of
the command methods.
:method:`Symfony\\Component\\Console\\Command\\Command::interact` *(optional)*
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. This is the last place
where you can ask for missing options/arguments. After this command,
missing options/arguments will result in an error.
:method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)*
This method is executed after ``interact()`` and ``initialize()``.
It contains the logic you want the command to execute.
Invoking other Commands
-----------------------
Expand Down

0 comments on commit 038a045

Please sign in to comment.