1- Creating Private Console Commands
2- =================================
1+ How to Hide Console Commands
2+ ============================
33
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.
76
87However, sometimes commands are not intended to be executed by end-users; for
98example, commands for the legacy parts of the application, commands exclusively
109executed through scheduled tasks, etc.
1110
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::
1413
1514 // src/AppBundle/Command/FooCommand.php
1615 namespace AppBundle\Command;
@@ -23,12 +22,11 @@ In those cases, you can define the command as **private** setting the
2322 {
2423 $this
2524 ->setName('app:foo')
25+ ->setHidden(true)
2626 // ...
27- ->setPublic(false)
2827 ;
2928 }
3029 }
3130
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