Skip to content

Commit

Permalink
新增「Artisan 命令-laravel:optimize-laravel:clean」功能
Browse files Browse the repository at this point in the history
  • Loading branch information
luisedware committed Aug 25, 2016
1 parent bf55f6d commit 6bcb672
Show file tree
Hide file tree
Showing 10 changed files with 436 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Free,open-source CMS based on the Laravel PHP Framework

- [x] 首页展示(Home Page)-- 初步实现,等待完善细节
- [x] 发送邮件(Send Email)-- 初步实现,等待重构
- [ ] 在线支付(Online payment
- [ ] 在线支付(Online Payment
- [x] 文件上传(File Upload)-- 初步实现,等待重构
- [ ] OAuth2.0 注册与登录(Register & Login By OAuth2.0)
- [ ] 富文本编辑器和 Markdown 编辑器(Rich Text Editor && Markdown)
Expand Down
70 changes: 70 additions & 0 deletions app/Console/Commands/LaravelClean.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

class LaravelClean extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'laravel:clean';

/**
* The console command description.
*
* @var string
*/
protected $description = 'clean project all cache';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->line("即将执行清除缓存命令");
if($this->confirm('确定执行?')){
$this->line("开始执行缓存命令");

Artisan::call("clear-compiled");

Artisan::call("auth:clear-resets");
$this->info('Expired reset tokens cleared!');

Artisan::call("cache:clear");
$this->info('Application cache cleared!');

Artisan::call("config:clear");
$this->info('Configuration cache cleared!');

Artisan::call("debugbar:clear");
$this->info('Debugbar Storage cleared!');

Artisan::call("route:clear");
$this->info('Route cache cleared!');

Artisan::call("view:clear");
$this->info('Compiled views cleared!');

$this->info("清除缓存成功");
} else {
$this->info("取消执行清除缓存命令");
}
}
}
68 changes: 68 additions & 0 deletions app/Console/Commands/LaravelOptimize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

class LaravelOptimize extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'laravel:optimize';

/**
* The console command description.
*
* @var string
*/
protected $description = 'optimize laravel project';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->line("即将执行优化缓存命令");
if($this->confirm('确定执行?')){
$this->line("开始执行缓存命令");

Artisan::call("config:cache");
$this->info('Configuration cache cleared!');
$this->info('Configuration cached successfully!');

Artisan::call("route:cache");
$this->info('Route cache cleared!');
$this->info('Routes cached successfully!');

Artisan::call("optimize");
$this->info('Generating optimized class loader');

if(function_exists('exec')){
exec("composer dump-autoload");
}

Artisan::call("ide-helper:generate");
$this->info('A new helper file was written to _ide_helper.php');

$this->info("优化缓存成功");
} else {
$this->info("取消执行优化缓存命令");
}
}
}
42 changes: 42 additions & 0 deletions app/Console/Commands/SendEmails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class SendEmails extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'emails:send';

/**
* The console command description.
*
* @var string
*/
protected $description = 'use SendCloud to send emails';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
8 changes: 6 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ class Kernel extends ConsoleKernel
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
\App\Console\Commands\SendEmails::class,
\App\Console\Commands\LaravelClean::class,
\App\Console\Commands\LaravelOptimize::class,
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
->hourly();
}
}
7 changes: 0 additions & 7 deletions app/Http/Routes/backend.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
<?php
/* 本地化切换 */
Route::get('language/{locale}', function ($locale) {
App::setLocale($locale);

return redirect()->route('backend.index.index');
});

/* 后台首页 */
Route::get('/', [
'as' => 'backend.index.index',
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"predis/predis": "~1.0",
"laravelcollective/html": "5.1.x-dev",
"zizaco/entrust": "5.2.x-dev",
"orangehill/iseed": "^2.1"
"orangehill/iseed": "^2.1",
"graham-campbell/exceptions": "^9.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
"phpspec/phpspec": "~2.1",
"filp/whoops": "^2.1"
},
"autoload": {
"classmap": [
Expand Down
133 changes: 131 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6bcb672

Please sign in to comment.