|
4 | 4 |
|
5 | 5 | use Illuminate\Console\Command;
|
6 | 6 | use LaravelOpcacheFacade\OpcacheFacade;
|
| 7 | +use LaravelOpcacheFacade\utils\CommandUtil; |
7 | 8 |
|
| 9 | +/** |
| 10 | + * Class StatusCommand |
| 11 | + * @package LaravelOpcacheFacade\Commands |
| 12 | + */ |
8 | 13 | class StatusCommand extends Command
|
9 | 14 | {
|
10 |
| - /** @var string The console command name.*/ |
| 15 | + /** @var string The console command name. */ |
11 | 16 | protected $signature = 'opcache:status';
|
12 | 17 |
|
13 |
| - /** @var string The console command description.*/ |
| 18 | + /** @var string The console command description. */ |
14 | 19 | protected $description = 'Get status information about the cache';
|
15 | 20 |
|
16 | 21 | /** @return mixed Execute the console command. */
|
17 | 22 | public function handle()
|
18 | 23 | {
|
19 | 24 | $info = OpcacheFacade::getStatus();
|
| 25 | + $base = $info; |
| 26 | + unset($base['memory_usage'], $base['interned_strings_usage'], $base['opcache_statistics']); |
| 27 | + |
20 | 28 | if ($info) {
|
| 29 | + $header = ['key', 'value']; |
| 30 | + |
| 31 | + $this->info('Base info:'); |
| 32 | + $this->table($header, CommandUtil::prepareTable($base), 'box-double'); |
| 33 | + |
| 34 | + if (isset($info['memory_usage'])) { |
| 35 | + $this->info('Memory usage:'); |
| 36 | + $this->table($header, CommandUtil::prepareTable($info['memory_usage']), 'box-double'); |
| 37 | + } |
| 38 | + |
| 39 | + if (isset($info['interned_strings_usage'])) { |
| 40 | + $this->info('Interned strings usage:'); |
| 41 | + $this->table($header, CommandUtil::prepareTable($info['interned_strings_usage']), 'box-double'); |
| 42 | + } |
21 | 43 |
|
| 44 | + if (isset($info['opcache_statistics'])) { |
| 45 | + $this->info('OPcache statistics:'); |
| 46 | + $this->table($header, CommandUtil::prepareTable($info['opcache_statistics']), 'box-double'); |
| 47 | + } |
22 | 48 | } else {
|
23 | 49 | $this->error('An error occurred while get status opcache');
|
24 | 50 | exit(2);
|
|
0 commit comments