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

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

In this post we will give you information about How to execute artisan commands from route or controller in Laravel ?. Hear we will give you detail about How to execute artisan commands from route or controller in Laravel ?And how to use it also give you demo for it if it is necessary.

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.

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.

Example:

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

/* php artisan migrate */

Artisan::call('migrate');

dd("Done");

});

I hope it can help you…

Hope this code and post will helped you for implement How to execute artisan commands from route or controller in Laravel ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

3  +  5  =  

We accept paid advance and paid guest Posting on our Site : Contact US