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 fda396e

Browse filesBrowse files
committed
[Console] Documented the Command::SUCCESS and Command::FAILURE constants
1 parent ba1d41e commit fda396e
Copy full SHA for fda396e

File tree

2 files changed

+18
-6
lines changed
Filter options

2 files changed

+18
-6
lines changed

‎console.rst

Copy file name to clipboardExpand all lines: console.rst
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,18 @@ want a command to create a user::
4747
{
4848
// ...
4949

50-
return 0;
50+
return Command::SUCCESS;
51+
52+
// or return this if some error happened during the execution:
53+
// return Command::FAILURE;
5154
}
5255
}
5356

57+
.. versionadded:: 5.1
58+
59+
The ``Command::SUCCESS`` and ``Command::FAILURE`` constants were introduced
60+
in Symfony 5.1.
61+
5462
Configuring the Command
5563
-----------------------
5664

@@ -149,7 +157,7 @@ the console::
149157
$output->write('You are about to ');
150158
$output->write('create a user.');
151159

152-
return 0;
160+
return Command::SUCCESS;
153161
}
154162

155163
Now, try executing the command:
@@ -200,7 +208,7 @@ which returns an instance of
200208
$section1->clear(2);
201209
// Output is now completely empty!
202210

203-
return 0;
211+
return Command::SUCCESS;
204212
}
205213
}
206214

@@ -242,7 +250,7 @@ Use input options or arguments to pass information to the command::
242250
// retrieve the argument value using getArgument()
243251
$output->writeln('Username: '.$input->getArgument('username'));
244252

245-
return 0;
253+
return Command::SUCCESS;
246254
}
247255

248256
Now, you can pass the username to the command:
@@ -293,7 +301,7 @@ as a service, you can use normal dependency injection. Imagine you have a
293301

294302
$output->writeln('User successfully generated!');
295303

296-
return 0;
304+
return Command::SUCCESS;
297305
}
298306
}
299307

‎console/lockable_trait.rst

Copy file name to clipboardExpand all lines: console/lockable_trait.rst
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ that adds two convenient methods to lock and release commands::
2727
if (!$this->lock()) {
2828
$output->writeln('The command is already running in another process.');
2929

30-
return 0;
30+
return Command::SUCCESS;
3131
}
3232

3333
// If you prefer to wait until the lock is released, use this:
@@ -41,4 +41,8 @@ that adds two convenient methods to lock and release commands::
4141
}
4242
}
4343

44+
.. versionadded:: 5.1
45+
46+
The ``Command::SUCCESS`` constant was introduced in Symfony 5.1.
47+
4448
.. _`locks`: https://en.wikipedia.org/wiki/Lock_(computer_science)

0 commit comments

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