File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,31 @@ This prints::
112
112
113
113
HELLO FABIEN
114
114
115
+ Command Lifecycle
116
+ ~~~~~~~~~~~~~~~~~
117
+
118
+ Commands have three lifecycle methods:
119
+
120
+ :method: `Symfony\\ Component\\ Console\\ Command\\ Command::initialize `
121
+ This method is executed before the ``interact() `` and the ``execute() ``
122
+ methods. It's main purpose is to initialize the variables used in the
123
+ rest of the command methods.
124
+
125
+ :method: `Symfony\\ Component\\ Console\\ Command\\ Command::interact `
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 otherwise the command
130
+ will throw an error.
131
+
132
+ :method: `Symfony\\ Component\\ Console\\ Command\\ Command::execute `
133
+ This method is executed after ``interact() `` and ``initialize() ``.
134
+ It contains the logic you want the command executes.
135
+
136
+ Note that ``execute() `` is the only required method of the three.
137
+
138
+ The ``initialize() `` and ``interact() `` methods are completely optional.
139
+
115
140
.. _components-console-coloring :
116
141
117
142
Coloring the Output
You can’t perform that action at this time.
0 commit comments