1
- Creating Private Console Commands
2
- =================================
1
+ How to Hide Console Commands
2
+ ============================
3
3
4
- Console commands are public by default, meaning that they are listed alongside
5
- other commands when executing the console application script without arguments
6
- or when using the ``list `` command.
4
+ By default, all console commands are listed when executing the console application
5
+ script without arguments or when using the ``list `` command.
7
6
8
7
However, sometimes commands are not intended to be executed by end-users; for
9
8
example, commands for the legacy parts of the application, commands exclusively
10
9
executed through scheduled tasks, etc.
11
10
12
- In those cases, you can define the command as **private ** setting the
13
- ``setPublic () `` method to ``false `` in the command configuration::
11
+ In those cases, you can define the command as **hidden ** by setting the
12
+ ``setHidden () `` method to ``true `` in the command configuration::
14
13
15
14
// src/AppBundle/Command/FooCommand.php
16
15
namespace AppBundle\Command;
@@ -23,12 +22,11 @@ In those cases, you can define the command as **private** setting the
23
22
{
24
23
$this
25
24
->setName('app:foo')
25
+ ->setHidden(true)
26
26
// ...
27
- ->setPublic(false)
28
27
;
29
28
}
30
29
}
31
30
32
- Private commands behave the same as public commands and they can be executed as
33
- before, but they are no longer displayed in command listings, so end-users are
34
- not aware of their existence.
31
+ Hidden commands behave the same as normal commands but they are no longer displayed
32
+ in command listings, so end-users are not aware of their existence.
0 commit comments