Skip to content

Commit 038a045

Browse files
committed
Move Command Lifecycle to guide
1 parent cbca1c0 commit 038a045

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

components/console.rst

-23
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,6 @@ This prints::
112112

113113
HELLO FABIEN
114114

115-
Command Lifecycle
116-
~~~~~~~~~~~~~~~~~
117-
118-
Commands have three lifecycle methods:
119-
120-
:method:`Symfony\\Component\\Console\\Command\\Command::initialize` *(optional)*
121-
This method is executed before the ``interact()`` and the ``execute()``
122-
methods. Its main purpose is to initialize variables used in the rest of
123-
the command methods.
124-
125-
:method:`Symfony\\Component\\Console\\Command\\Command::interact` *(optional)*
126-
This method is executed after ``initialize()`` and before ``execute()``.
127-
Its purpose is to check if some of the options/arguments are missing
128-
and interactively ask the user for those values. This is the last place
129-
where you can ask for missing options/arguments. After this command,
130-
missing options/arguments will result in an error.
131-
132-
:method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)*
133-
This method is executed after ``interact()`` and ``initialize()``.
134-
It contains the logic you want the command to execute.
135-
136-
137-
138115
Console Helpers
139116
---------------
140117

console.rst

+22
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,28 @@ Now, once you created the required services and logic, the command will execute
198198
the ``generate()`` method of the ``app.admin_generator`` service and the admin
199199
will be created.
200200
201+
Command Lifecycle
202+
~~~~~~~~~~~~~~~~~
203+
204+
Commands have three lifecycle methods that are invoked when running the
205+
command:
206+
207+
:method:`Symfony\\Component\\Console\\Command\\Command::initialize` *(optional)*
208+
This method is executed before the ``interact()`` and the ``execute()``
209+
methods. Its main purpose is to initialize variables used in the rest of
210+
the command methods.
211+
212+
:method:`Symfony\\Component\\Console\\Command\\Command::interact` *(optional)*
213+
This method is executed after ``initialize()`` and before ``execute()``.
214+
Its purpose is to check if some of the options/arguments are missing
215+
and interactively ask the user for those values. This is the last place
216+
where you can ask for missing options/arguments. After this command,
217+
missing options/arguments will result in an error.
218+
219+
:method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)*
220+
This method is executed after ``interact()`` and ``initialize()``.
221+
It contains the logic you want the command to execute.
222+
201223
Invoking other Commands
202224
-----------------------
203225

0 commit comments

Comments
 (0)