Answer the question
In order to leave comments, you need to log in
How to pass an option as a string in the Symfony console?
There is a command, in the option of which you need to pass a string.
php app/console acme:email:send --created='-3 days'
protected function configure()
{
// ...
$this->addOption(
'created',
null,
InputOption::VALUE_OPTIONAL,
'Days ago?',
"-1 day"
);
);
protected function execute(InputInterface $input, OutputInterface $output)
{
var_dump($input->getOption('created'));
}
// output:
'-3 days'
php app/console acme:email:send --created=\"-3 days\"
// output:
\-3 days\
Answer the question
In order to leave comments, you need to log in
Do you need '-3 days' ? These are options, just type --created=-3 --format=days . Or use arguments for this and you will be happy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question