File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,31 @@ This prints::
110110
111111 HELLO FABIEN
112112
113+ Command Lifecycle
114+ ~~~~~~~~~~~~~~~~~
115+
116+ Commands have three lifecycle methods:
117+
118+ :method: `Symfony\\ Component\\ Console\\ Command\\ Command::initialize `
119+ This method is executed before the ``interact() `` and the ``execute() ``
120+ methods. It's main purpose is to initialize the variables used in the
121+ rest of the command methods.
122+
123+ :method: `Symfony\\ Component\\ Console\\ Command\\ Command::interact `
124+ This method is executed after ``initialize() `` and before ``execute() ``.
125+ Its purpose is to check if some of the options/arguments are missing
126+ and interactively ask the user for those values. This is the last place
127+ where you can ask for missing options/arguments otherwise the command
128+ will throw an error.
129+
130+ :method: `Symfony\\ Component\\ Console\\ Command\\ Command::execute `
131+ This method is executed after ``interact() `` and ``initialize() ``.
132+ It contains the logic you want the command executes.
133+
134+ Note that ``execute() `` is the only required method of the three.
135+
136+ The ``initialize() `` and ``interact() `` methods are completely optional.
137+
113138.. _components-console-coloring :
114139
115140Coloring the Output
You can’t perform that action at this time.
0 commit comments