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:
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:
implode(" ", $_SERVER['argv'])
Example:
class SomeCommand extends ContainerAwareCommand { protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln( implode(" ", $_SERVER['argv']) ); } }