diff --git a/book/routing.rst b/book/routing.rst index 30453bee220..3aac5675d3d 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -989,7 +989,7 @@ variables that are passed into the expression: Behind the scenes, expressions are compiled down to raw PHP. Our example would generate the following PHP in the cache directory:: - if (rtrim($pathinfo, '/contact') === '' && ( + if ($pathinfo === '/contact' && ( in_array($context->getMethod(), array(0 => "GET", 1 => "HEAD")) && preg_match("/firefox/i", $request->headers->get("User-Agent")) )) { diff --git a/console/private_commands.rst b/console/private_commands.rst new file mode 100644 index 00000000000..a534667ad44 --- /dev/null +++ b/console/private_commands.rst @@ -0,0 +1,34 @@ +Creating Private Console Commands +================================= + +Console commands are public by default, meaning that they are listed alongside +other commands when executing the console application script without arguments +or when using the ``list`` command. + +However, sometimes commands are not intended to be executed by end-users; for +example, commands for the legacy parts of the application, commands exclusively +executed through scheduled tasks, etc. + +In those cases, you can define the command as **private** setting the +``setPublic()`` method to ``false`` in the command configuration:: + + // src/AppBundle/Command/FooCommand.php + namespace AppBundle\Command; + + use Symfony\Component\Console\Command\Command; + + class FooCommand extends Command + { + protected function configure() + { + $this + ->setName('app:foo') + // ... + ->setPublic(false) + ; + } + } + +Private commands behave the same as public commands and they can be executed as +before, but they are no longer displayed in command listings, so end-users are +not aware of their existence.