Thursday, April 13, 2017

Laravel/Lumen: run command using string as arguments

Laravel documentation states we can run a command using following syntax in PHP:

$this->call('email:send', [
    'user' => 1, '--queue' => 'default'
]);

What if I have a command as string, is it possible to run it using a syntax like:

$this->call('email:send', '--fs here --user 22 tag=yes');

What is the problem? Having a command as string, it gets so hard to programmatically convert the string to a working array. For example in the previous example, index of here string will be defined based on the email:send command signature. So I hope there is a way to run commands using strings or is there any way to convert given string to a working array, based on the command signature?



via HPM

Advertisement