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

You want to pass a non-option argument to a Laravel command? You won’t find this in documentation, but it’s easy to do:

php artisan posts:generate  ---public  ---count=5

Equivalent of the above with Artisan::call is as follows

Artisan::call(
    command: 'posts:generate',
    arguments: [
       '--public' => true,
       'count' =>5
    ]
);

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *