Skip to content

Instantly share code, notes, and snippets.

@rkbi
Created July 24, 2021 18:45
Show Gist options
  • Save rkbi/2ca58cc13d9c054643f038630d6bee83 to your computer and use it in GitHub Desktop.
Save rkbi/2ca58cc13d9c054643f038630d6bee83 to your computer and use it in GitHub Desktop.
Laravel routes for artisan commands
<?php
use Illuminate\Support\Facades\Artisan;
Route::get('/clearing-cache', function() {
$exitCode = Artisan::call('cache:clear');
return '<h1>Cache facade value cleared</h1>';
});
Route::get('/optimize', function() {
$exitCode = Artisan::call('optimize');
return '<h1>Reoptimized class loader</h1>';
});
Route::get('/route-cache', function() {
$exitCode = Artisan::call('route:cache');
return '<h1>Routes cached</h1>';
});
Route::get('/route-clearing', function() {
$exitCode = Artisan::call('route:clear');
return '<h1>Route cache cleared</h1>';
});
Route::get('/view-clearing', function() {
$exitCode = Artisan::call('view:clear');
return '<h1>View cache cleared</h1>';
});
Route::get('/config-cache', function() {
$exitCode = Artisan::call('config:cache');
return '<h1>Clearing Config cleared</h1>';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment