File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
components/console/helpers Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,34 @@ the second argument is not provided, ``true`` is assumed.
6666
6767 The regex defaults to ``/^y/i ``.
6868
69+ .. note ::
70+
71+ When your output implements ``ConsoleOutputInterface `` the ``stderr `` output is used using :method: `ConsoleOutputInterface::getErrorOutput `.
72+ This output might have a different formatter than the default one. This might lead to unexpected results.
73+ If this is the case, you can apply custom styles directly on to the error output::
74+
75+ use Symfony\Component\Console\Formatter\OutputFormatterStyle;
76+ use Symfony\Component\Console\Output\ConsoleOutputInterface;
77+ use Symfony\Component\Console\Question\Question;
78+
79+ // ...
80+ public function execute(InputInterface $input, OutputInterface $output)
81+ {
82+ // ...
83+ $question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle');
84+
85+ if($output instanceof ConsoleOutputInterface) {
86+ $output = $output->getErrorOutput();
87+ }
88+
89+ $outputStyle = new OutputFormatterStyle('red', 'yellow', ['bold', 'blink']);
90+ $questionOutput->getFormatter()->setStyle('fire', $outputStyle);
91+
92+ $bundleName = $helper->ask($input, $output, $question);
93+ }
94+
95+ More information on formatting can be found on the :doc: `/components/console/helpers/formatterhelper ` page.
96+
6997Asking the User for Information
7098-------------------------------
7199
You can’t perform that action at this time.
0 commit comments