Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2d1c06

Browse filesBrowse files
JeremieSamsonjaviereguiluz
authored andcommitted
Update console.rst
Since Symfony 5.0, we have an error if we don't return an int on the `execute` function, I added it in the doc so there will not be an `TypeError` when trying this.
1 parent 214ffe2 commit e2d1c06
Copy full SHA for e2d1c06

File tree

Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed

‎console.rst

Copy file name to clipboardExpand all lines: console.rst
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ the console::
146146
// outputs a message without adding a "\n" at the end of the line
147147
$output->write('You are about to ');
148148
$output->write('create a user.');
149+
150+
return 0;
149151
}
150152

151153
Now, try executing the command:
@@ -195,6 +197,8 @@ which returns an instance of
195197
// (this example deletes the last two lines of the section)
196198
$section1->clear(2);
197199
// Output is now completely empty!
200+
201+
return 0;
198202
}
199203
}
200204

@@ -235,6 +239,8 @@ Use input options or arguments to pass information to the command::
235239

236240
// retrieve the argument value using getArgument()
237241
$output->writeln('Username: '.$input->getArgument('username'));
242+
243+
return 0;
238244
}
239245

240246
Now, you can pass the username to the command:
@@ -284,6 +290,8 @@ as a service, you can use normal dependency injection. Imagine you have a
284290
$this->userManager->create($input->getArgument('username'));
285291

286292
$output->writeln('User successfully generated!');
293+
294+
return 0;
287295
}
288296
}
289297

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.