Search code examples
laravelconsolepublishlaravel-artisanvendor

laravel 5.1 Artisan::call() parameter --tag for vendor:publish not working


im using console to call multiple vendor to publish my seeding data, but unfortunatelly i got this error

try 1

Artisan::call('vendor:publish',
[
    '--provider' => 'Package\MyPackage\CoreServiceProvider',
    '--tag' => 'seeds',
    '--force' => true
]);

error message

[ErrorException]                         
Invalid argument supplied for foreach()

try 2 (success without tag parameter)

i remove --tag and no error

Artisan::call('vendor:publish',
[
    '--provider' => 'Package\MyPackage\CoreServiceProvider',
    '--force' => true
]);

when i run code on my terminal it's fine php artisan vendor:publish --provider="Package\MyPackage\CoreServiceProvider" --tag=seeds --force


Solution

  • after more trial and error i got solutions,

    i must use array for --tag parameter

    Artisan::call('vendor:publish',
    [
        '--provider' => 'Package\MyPackage\CoreServiceProvider',
        '--tag' => ['seeds'],
        '--force' => true
    ]);