How to execute artisan commands from route or controller in Laravel ?

By Hardik Savani October 10, 2020 Category : Laravel

Sometimes we require to run php artisan command from route or controller file in out Laravel Application, However we can do it using Artisan facade. Laravel Artisan facade that way we can easily run all artisan command with argument. you can also use this example in laravel 6, laravel 7, laravel 8 and laravel 9.

Artisan facade have two method call() and queue(), queue() through we can simply make process in queue like email sending etc. So let's see simple example with route. In this example we run "php artisan migrate" command using artisan facade. Here i bellow example you can learn how you can run artisan commands from route.


Route::get('command', function () {

/* php artisan migrate */




I hope it can help you...