Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Add optimize and optimize:clear commands #23468

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Illuminate/Foundation/Console/OptimizeClearCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Illuminate\Foundation\Console;

use Illuminate\Console\Command;

class OptimizeClearCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'optimize:clear';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear all caches (routes, config, views, compiled class)';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->call('cache:clear');
$this->call('route:clear');
$this->call('view:clear');
$this->call('clear-compiled');

vinkla marked this conversation as resolved.
Show resolved Hide resolved
$this->info('Config, routes and view cache cleared successfully!');
}
}
37 changes: 37 additions & 0 deletions src/Illuminate/Foundation/Console/OptimizeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Illuminate\Foundation\Console;

use Illuminate\Console\Command;

class OptimizeCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'optimize';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Optimize everything (cache routes, config)';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->call('cache:clear');
$this->call('config:cache');
$this->call('route:clear');
vinkla marked this conversation as resolved.
Show resolved Hide resolved
$this->call('route:cache');

$this->info('Config and routes cached successfully!');
}
}
28 changes: 28 additions & 0 deletions src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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.
*
Expand Down