Closed nbertal closed 11 years ago
I think it's the same as #3 so you need to type artisan command:example userid=12 role=sell
. I have to look into it whether I can fix this or not, as it's the way Artisan:call
works
Indeed, it looks like a Laravel issue / limitation on Artisan::call(). http://forums.laravel.io/viewtopic.php?id=8307 Not sure whether an issue is opened there, but meanwhile I am going to use the command you recommended.
A possible workaround might be to assign the keys to each values based on what's in getArguments (first making sure it's not option) ? [Cmd.php foreach loop line 65]
Yeah that would be the workaround I'll use but I need to implement it first
Thanks !
Ok I have it nor to a point where I have an instance of the command itself:
$app = app();
$app->loadDeferredProviders();
$artisan = ConsoleApplication::start($app);
$command = $artisan->find($cmd);
But the problem is now that I need to have the arguments/options to check the input against it, but the functions getArguments
and getOptions
are protected. Any thoughts on this?
Ok found a (dirty) way:
$def = $command->getDefinition();
$arguments = $def->getArguments();
$fix = array();
foreach($arguments as $argument) {
$fix[] = $argument->getName();
}
$arguments = $fix;
$options = $def->getOptions();
$fix = array();
foreach($options as $option) {
$fix[] = $option->getName();
}
$options = $fix;
Now working on the workaround itself...
Ok fixed it, the way the new function works isn't the best but I hadn't any other thoughts on this. If someone finds a better way, feel free to make a Pull Request
Me again, When making a custom command that uses arguments, they are not taken properly into considerations:
In my command "example" I set
Then when launching in regular artisan I can do: => artisan command:example 12 sell it works fine
but in web-artisan it looks like there is a confusion between arguments and options, launching the same command raises: Error (InvalidArgumentException): The "12" argument does not exist. in ....\vendor\symfony\console\Symfony\Component\Console\Input\ArrayInput.php (204)
If instead I type the name of the argument, it raises no error, but obsviously I cannot proceed since values need to be passed.