Skip to content

Instantly share code, notes, and snippets.

@mrunknown0001
Last active July 16, 2025 23:22
Show Gist options
  • Select an option

  • Save mrunknown0001/0e7ccf39aa40dec9eb6a059a24e2cc79 to your computer and use it in GitHub Desktop.

Select an option

Save mrunknown0001/0e7ccf39aa40dec9eb6a059a24e2cc79 to your computer and use it in GitHub Desktop.
Custom Console for Automated Optimization of Laravel Application
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
class ClearOptimize extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'clear:optimize';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Optimize, clear cache, and cache views and routes';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
Command::call('optimize:clear');
Command::call('view:cache');
Command::call('route:cache');
$this->info("Application is optimized, and views and routes are cached!");
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment