Sometimes you may wish to execute an Artisan command outside of the CLI. For example, you may wish to fire an Artisan command from an HTTP route. Just use the
Artisan
facade:Route::get('/foo', function()
{
$exitCode = Artisan::call('command:name', ['--option' => 'foo']);
//
});
You may even queue Artisan commands so they are processed in the background by your queue workers:
Route::get('/foo', function()
{
Artisan::queue('command:name', ['--option' => 'foo']);
//
});
No comments:
Post a Comment