Quantcast
Channel: Symfony Blog
Viewing all articles
Browse latest Browse all 3088

New in Symfony 3.2: Console Improvements (Part 3)

$
0
0

Read the part 1 and part 2 of this series of articles explaining the new features of the Console component in Symfony 3.2.

Added support for multiple text style options

SpacePossum

Contributed by
SpacePossum
in #19495.

The output of the console commands can use any of these text styles to change its appearance: bold, underscore, blink, reverse and conceal. In Symfony 3.2, you can combine more than one text style for a single content (for example to display some text bold and underscored):

1
$output->writeln('<fg=green;options=bold,underscore>Test</>');

In any case, remember that Symfony provides a simpler way toapply the same style to your console commands in a consistent way.

Added support for private commands

Jordan Deitch

Contributed by
Jordan Deitch
in #20029.

By default Symfony commands are public, so they are always included in the command listings displayed when running bin/console or bin/console list. In Symfony 3.2, you can remove some commands from those listings making them private with the setPublic(false) method:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
// src/AppBundle/Command/FooCommand.phpnamespaceAppBundle\Command;useSymfony\Component\Console\Command\Command;classFooCommandextendsCommand{protectedfunctionconfigure(){$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. They are best suited for commands designed for the legacy parts of the application, for commands exclusively executed through scheduled tasks, etc.


Be trained by Symfony experts - 2016-10-17 Paris - 2016-10-24 Paris - 2016-10-24 Lyon

Viewing all articles
Browse latest Browse all 3088

Trending Articles