I got a custom command in Laravel 5, that gets username and password.
One user got his password starting with a dash, something like -819830219', making laravel return a error saying "The -8 option does not exist.
I tried setting the password between quotation marks and still got the same error.
Is there a way to pass a parameter that starts with a dash that laravel will not understand as a option?
protected function getArguments()
{
return [
['username', InputArgument::REQUIRED, 'Partner\'s username.'],
['password', InputArgument::REQUIRED, 'Partner\'s password.'],
['origin', InputArgument::REQUIRED, 'Partner\'s origin code.'],
];
}
You can escape the -
character by prepending it with --
like:
php artisan command -- -819830219
Or you can use an interactive command like this:
public function handle()
{
$username = $this->ask('Enter username');
$password = $this->secret('Enter password');
$origin = $this->ask('Enter origin');
$this->doSomething($username, $password, $origin);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With