Created
September 7, 2012 11:46
-
-
Save MattKetmo/3665488 to your computer and use it in GitHub Desktop.
[Console] Write into stdout and stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\ConsoleOutputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
/** | |
* Testcase: app/console foo > std 2> err | |
*/ | |
class FooCommand extends Command | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function configure() | |
{ | |
$this | |
->setName('foo') | |
; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; | |
$output->writeln('<info>standard message</info>'); | |
$errOutput->writeln('<error>error message</error>'); | |
} | |
} |
Nice! Thank you :)
cool, thx!
thx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks