-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel.php
executable file
·33 lines (23 loc) · 971 Bytes
/
kernel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use App\Application\Command\DatabaseUpdateCommand;
use App\Application\Controller\IpInfoController;
use App\Application\Database\DatabaseConnectionProvider;
use App\MaxMind\MaxMindCredentials;
use App\MaxMind\MaxMindUpdater;
use Symfony\Component\Console\Application;
$config = include __DIR__ . '/config.php';
$connectionProvider = new DatabaseConnectionProvider($config['connection']);
if (php_sapi_name() === 'cli') {
$application = new Application();
$application->add(new DatabaseUpdateCommand(new MaxMindUpdater($connectionProvider, new MaxMindCredentials(
(int) $config['maxmind']['accountId'],
$config['maxmind']['licenseKey'],
))));
$application->setDefaultCommand(DatabaseUpdateCommand::getDefaultName());
/** @noinspection PhpUnhandledExceptionInspection */
exit($application->run());
} else {
(new IpInfoController($connectionProvider))($_GET['ip'] ?? null);
}