1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of DivineNii opensource projects. |
7
|
|
|
* |
8
|
|
|
* PHP version 7.4 and above required |
9
|
|
|
* |
10
|
|
|
* @author Divine Niiquaye Ibok <[email protected]> |
11
|
|
|
* @copyright 2019 DivineNii (https://divinenii.com/) |
12
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause License |
13
|
|
|
* |
14
|
|
|
* For the full copyright and license information, please view the LICENSE |
15
|
|
|
* file that was distributed with this source code. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace Rade\Commands; |
19
|
|
|
|
20
|
|
|
use Rade\Application; |
21
|
|
|
use Rade\DI\ContainerInterface; |
22
|
|
|
use Symfony\Component\Console\Command\Command; |
23
|
|
|
use Symfony\Component\Console\Helper\TableSeparator; |
24
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
25
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
26
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* A console command to display information about the current project. |
30
|
|
|
* |
31
|
|
|
* @author Divine Niiquaye Ibok <[email protected]> |
32
|
|
|
* |
33
|
|
|
* @final |
34
|
|
|
*/ |
35
|
|
|
class AboutCommand extends Command |
36
|
|
|
{ |
37
|
|
|
protected static $defaultName = 'about'; |
38
|
|
|
|
39
|
|
|
protected static $defaultDescription = 'Display information about the current project'; |
40
|
|
|
|
41
|
|
|
private ContainerInterface $container; |
42
|
|
|
|
43
|
|
|
public function __construct(ContainerInterface $container) |
44
|
|
|
{ |
45
|
|
|
$this->container = $container; |
46
|
|
|
parent::__construct(self::$defaultName); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
protected function configure(): void |
53
|
|
|
{ |
54
|
|
|
$this->setHelp( |
55
|
|
|
<<<'EOT' |
56
|
|
|
The <info>%command.name%</info> command displays information about the current PHP Rade project. |
57
|
|
|
|
58
|
|
|
The <info>PHP</info> section displays important configuration that could affect your application. The values might |
59
|
|
|
be different between web and CLI. |
60
|
|
|
EOT |
61
|
|
|
) |
62
|
|
|
; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
*/ |
68
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
69
|
|
|
{ |
70
|
|
|
$io = new SymfonyStyle($input, $output); |
71
|
|
|
$container = $this->container; |
72
|
|
|
|
73
|
|
|
$rows = [ |
74
|
|
|
['<info>PHP Rade Framework</>'], |
75
|
|
|
new TableSeparator(), |
76
|
|
|
['Version', Application::VERSION], |
77
|
|
|
['Long-Term Support', 4 === Application::VERSION[2] ? 'Yes' : 'No'], |
78
|
|
|
new TableSeparator(), |
79
|
|
|
['<info>Kernel</>'], |
80
|
|
|
new TableSeparator(), |
81
|
|
|
['Container', \get_class($container)], |
82
|
|
|
['Debug', $container instanceof Application ? ($container->isDebug() ? 'true' : 'false') : 'n/a'], |
83
|
|
|
new TableSeparator(), |
84
|
|
|
['<info>PHP</>'], |
85
|
|
|
new TableSeparator(), |
86
|
|
|
['Version', \PHP_VERSION], |
87
|
|
|
['Architecture', (\PHP_INT_SIZE * 8) . ' bits'], |
88
|
|
|
['Intl locale', \class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'], |
89
|
|
|
['Timezone', \date_default_timezone_get() . ' (<comment>' . (new \DateTime())->format(\DateTime::W3C) . '</>)'], |
90
|
|
|
['OPcache', \extension_loaded('Zend OPcache') && \filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], |
91
|
|
|
['APCu', \extension_loaded('apcu') && \filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], |
92
|
|
|
['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'], |
93
|
|
|
]; |
94
|
|
|
|
95
|
|
|
$io->table([], $rows); |
96
|
|
|
|
97
|
|
|
return 0; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|