I am creating a console command in symfony2. I need to log an executed line i run. How to get that line?
So if i run:
JavaScript
x
php app/console my-command fileName.txt --myoption=100
I want to get value “php app/console my-command fileName.txt –myoption=100”
Thanks for any help
Advertisement
Answer
I’m interpreting the question as: Within the Command code itself, you want to determine what was written on the command line in order to end up executing that Symfony Command?
If that’s correct, then I don’t think it’s possible to get it exactly. However, you should be able to get [almost?] the same effect by doing this:
JavaScript
implode(" ", $_SERVER['argv'])
Example:
JavaScript
class SomeCommand extends ContainerAwareCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln( implode(" ", $_SERVER['argv']) );
}
}