Call Artisan commands directly from the code

Asked

Viewed 65 times

1

Hello! I am studying Arabic, and I would like to know if it is possible to call the Artisan commands in the Controllers. Example: When the user clicks on the button he executes an Artisan command, a routine or something related.

1 answer

1


The version of Laravel was missing but at least in 5.1 you can use the Facade of Artisan

use Illuminate\Support\Facades\Artisan;

and within the function:

Artisan::call('down');

In the example I gave the Laravel was put in maintenance mode.

  • Thank you! That’s exactly what I was looking for!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.