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.
66
66
67
67
The regex defaults to ``/^y/i ``.
68
68
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\Question\Question;
77
+ use Symfony\Component\Console\Output\ConsoleOutputInterface;
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($questionOutput instanceof ConsoleOutputInterface) {
86
+ $questionOutput = $output->getErrorOutput();
87
+ }
88
+
89
+ $outputStyle = new OutputFormatterStyle('red', 'yellow', ['bold', 'blink']);
90
+ $questionOutput->getFormatter()->setStyle('fire', $outputStyle);
91
+
92
+ $bundleName = $helper->ask($input, $questionOutput, $question);
93
+ }
94
+
95
+ More information on formatting can be found on the :doc: `/components/console/helpers/formatterhelper ` page.
96
+
69
97
Asking the User for Information
70
98
-------------------------------
71
99
You can’t perform that action at this time.
0 commit comments