Laravel run artisan command from controller

2024-03-19 04:39:29 Anil Singh Laravel

In this trick you will see how to run artisan command from laravel controller


In routes/web.php


Route::get('/run-artisan-command-xyz','MyController@runArtisanCommand');


In your Controller


public function runArtisanCommand(){

	\Artisan::call('command:name', ['--option' => 'foo']);
}


This post is submitted by one of our members. You may submit a new post here.

Related Tricks