Framework: Artisan::call() doesn't accept unnamed arguments

Created on 4 Apr 2018  路  10Comments  路  Source: laravel/framework

  • Laravel Version: 5.5.32
  • PHP Version: 7.2

Description:

Used to be, you could call Artisan::call('list', ['' => 'view']); which would be analogous to calling php artisan list view but this doesn't work anymore.

Is there any other way to pass an argument?

Most helpful comment

@aleemb try Artisan::call('list', ['<name of argument>' => 'view']);

All 10 comments

Optional arguments would be a better solution: email:send {user?}

@aleemb try Artisan::call('list', ['<name of argument>' => 'view']);

@Quezler as mentioned in the description, it's a nameless argument analogous to artisan list view

Could you share the signature/name/arguments code from the command in question?

@Quezler it's in the bug description and again in my response above. The example command is artisan list view. For example

> artisan list view

Available commands for the "view" namespace:
  view:clear  Clear all compiled view files

Now try running the same command via Artisan::call(...) and getting the same output.

@aleemb give this a try:

$this->call('list', [
    'namespace' => 'view'
]);

or in your case:

Artisan::call('list', [
    'namespace' => 'view'
]);

the named arguments can be found on symfony/console's ListCommand.php

That works, thanks very much!

@Quezler Another hurdle is that while this works for artisan list view it doesn't work for artisan tinker /tmp/foo. The tinker cli command accepts a path as an argument. The error is that 'The "namespace" argument does not exist. I suspect this isn't a generic solution unless tinker is a special case.

These are the arguments for the TinkerCommand.php:

    return [
        ['include', InputArgument::IS_ARRAY, 'Include file(s) before starting tinker'],
    ];

Thanks again, that worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kerbylav picture kerbylav  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

jackmu95 picture jackmu95  路  3Comments

JamborJan picture JamborJan  路  3Comments

felixsanz picture felixsanz  路  3Comments