File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ Creating Private Console Commands
2
+ =================================
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.
7
+
8
+ However, sometimes commands are not intended to be executed by end-users; for
9
+ example, commands for the legacy parts of the application, commands exclusively
10
+ executed through scheduled tasks, etc.
11
+
12
+ In those cases, you can define the command as **private ** setting the
13
+ ``setPublic() `` method to ``false `` in the command configuration::
14
+
15
+ // src/AppBundle/Command/FooCommand.php
16
+ namespace AppBundle\Command;
17
+
18
+ use Symfony\Component\Console\Command\Command;
19
+
20
+ class FooCommand extends Command
21
+ {
22
+ protected function configure()
23
+ {
24
+ $this
25
+ ->setName('app:foo')
26
+ // ...
27
+ ->setPublic(false)
28
+ ;
29
+ }
30
+ }
31
+
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.
You can’t perform that action at this time.
0 commit comments