Using Artisan::call() to pass non-option arguments

Artisan::call('db:migrate', ['' => 'mymigration', '--table' => 'mytable']) should work.

Incidentally db:migrate isn't an artisan command out of the box. Are you sure this is correct?


In laravel 5.1 , you set options with/without values when calling an Artisan command from your PHP code.

Artisan::call('your:commandname', ['--optionwithvalue' => 'youroptionvalue', '--optionwithoutvalue' => true]);

in this case, inside your artisan command;

$this->option('optionwithvalue'); //returns 'youroptionvalue'

$this->option('optionwithoutvalue'); //returns true

The solution is different if you're using Laravel 5.1 or newer. Now what you need to do is you need to know the name that was given to the argument in the command's signature. You can find the name of the argument from your command shell by using php artisan help followed by the command name.

I think you meant to ask about "make:migration". So, for example php artisan help make:migration shows you that it accepts a parameter called "name". So you can call it like this: Artisan::call('make:migration', ['name' => 'foo' ]).