From fe1cbdf3b51ce1235b8c91f5e603f1e9306e4f6f Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Fri, 9 Mar 2018 20:14:12 +0100 Subject: [PATCH] Add optimize and optimize:clear commands --- .../Console/OptimizeClearCommand.php | 37 +++++++++++++++++++ .../Foundation/Console/OptimizeCommand.php | 37 +++++++++++++++++++ .../Providers/ArtisanServiceProvider.php | 28 ++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 src/Illuminate/Foundation/Console/OptimizeClearCommand.php create mode 100644 src/Illuminate/Foundation/Console/OptimizeCommand.php diff --git a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php new file mode 100644 index 000000000000..8e205160c7cc --- /dev/null +++ b/src/Illuminate/Foundation/Console/OptimizeClearCommand.php @@ -0,0 +1,37 @@ +call('cache:clear'); + $this->call('route:clear'); + $this->call('view:clear'); + $this->call('clear-compiled'); + + $this->info('Config, routes and view cache cleared successfully!'); + } +} diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php new file mode 100644 index 000000000000..5d537bf97c27 --- /dev/null +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -0,0 +1,37 @@ +call('cache:clear'); + $this->call('config:cache'); + $this->call('route:clear'); + $this->call('route:cache'); + + $this->info('Config and routes cached successfully!'); + } +} diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 6fe0655a9848..f1c095a62598 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -16,6 +16,7 @@ use Illuminate\Foundation\Console\JobMakeCommand; use Illuminate\Database\Console\Seeds\SeedCommand; use Illuminate\Foundation\Console\MailMakeCommand; +use Illuminate\Foundation\Console\OptimizeCommand; use Illuminate\Foundation\Console\RuleMakeCommand; use Illuminate\Foundation\Console\TestMakeCommand; use Illuminate\Foundation\Console\EventMakeCommand; @@ -43,6 +44,7 @@ use Illuminate\Foundation\Console\ClearCompiledCommand; use Illuminate\Foundation\Console\EventGenerateCommand; use Illuminate\Foundation\Console\ExceptionMakeCommand; +use Illuminate\Foundation\Console\OptimizeClearCommand; use Illuminate\Foundation\Console\VendorPublishCommand; use Illuminate\Console\Scheduling\ScheduleFinishCommand; use Illuminate\Database\Console\Seeds\SeederMakeCommand; @@ -99,6 +101,8 @@ class ArtisanServiceProvider extends ServiceProvider 'MigrateReset' => 'command.migrate.reset', 'MigrateRollback' => 'command.migrate.rollback', 'MigrateStatus' => 'command.migrate.status', + 'Optimize' => 'command.optimize', + 'OptimizeClear' => 'command.optimize.clear', 'PackageDiscover' => 'command.package.discover', 'Preset' => 'command.preset', 'QueueFailed' => 'command.queue.failed', @@ -587,6 +591,30 @@ protected function registerNotificationMakeCommand() }); } + /** + * Register the command. + * + * @return void + */ + protected function registerOptimizeCommand() + { + $this->app->singleton('command.optimize', function ($app) { + return new OptimizeCommand; + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerOptimizeClearCommand() + { + $this->app->singleton('command.optimize.clear', function ($app) { + return new OptimizeClearCommand; + }); + } + /** * Register the command. *