Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Console/Commands/InfoCommand.php
7459 views
1
<?php
2
3
namespace Pterodactyl\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Pterodactyl\Services\Helpers\SoftwareVersionService;
7
use Illuminate\Contracts\Config\Repository as ConfigRepository;
8
9
class InfoCommand extends Command
10
{
11
protected $description = 'Displays the application, database, and email configurations along with the panel version.';
12
13
protected $signature = 'p:info';
14
15
/**
16
* VersionCommand constructor.
17
*/
18
public function __construct(private ConfigRepository $config, private SoftwareVersionService $versionService)
19
{
20
parent::__construct();
21
}
22
23
/**
24
* Handle execution of command.
25
*/
26
public function handle()
27
{
28
$this->output->title('Version Information');
29
$this->table([], [
30
['Panel Version', $this->config->get('app.version')],
31
['Latest Version', $this->versionService->getPanel()],
32
['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')],
33
['Unique Identifier', $this->config->get('pterodactyl.service.author')],
34
], 'compact');
35
36
$this->output->title('Application Configuration');
37
$this->table([], [
38
['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')],
39
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', !$this->config->get('app.debug') ?: 'bg=red')],
40
['Installation URL', $this->config->get('app.url')],
41
['Installation Directory', base_path()],
42
['Timezone', $this->config->get('app.timezone')],
43
['Cache Driver', $this->config->get('cache.default')],
44
['Queue Driver', $this->config->get('queue.default')],
45
['Session Driver', $this->config->get('session.driver')],
46
['Filesystem Driver', $this->config->get('filesystems.default')],
47
['Default Theme', $this->config->get('themes.active')],
48
['Proxies', $this->config->get('trustedproxies.proxies')],
49
], 'compact');
50
51
$this->output->title('Database Configuration');
52
$driver = $this->config->get('database.default');
53
$this->table([], [
54
['Driver', $driver],
55
['Host', $this->config->get("database.connections.$driver.host")],
56
['Port', $this->config->get("database.connections.$driver.port")],
57
['Database', $this->config->get("database.connections.$driver.database")],
58
['Username', $this->config->get("database.connections.$driver.username")],
59
], 'compact');
60
61
// TODO: Update this to handle other mail drivers
62
$this->output->title('Email Configuration');
63
$this->table([], [
64
['Driver', $this->config->get('mail.default')],
65
['Host', $this->config->get('mail.mailers.smtp.host')],
66
['Port', $this->config->get('mail.mailers.smtp.port')],
67
['Username', $this->config->get('mail.mailers.smtp.username')],
68
['From Address', $this->config->get('mail.from.address')],
69
['From Name', $this->config->get('mail.from.name')],
70
['Encryption', $this->config->get('mail.mailers.smtp.encryption')],
71
], 'compact');
72
}
73
74
/**
75
* Format output in a Name: Value manner.
76
*/
77
private function formatText(string $value, string $opts = ''): string
78
{
79
return sprintf('<%s>%s</>', $opts, $value);
80
}
81
}
82
83