-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstartup.php
executable file
·48 lines (40 loc) · 1.31 KB
/
startup.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
use Dotenv\Dotenv;
use Jinya\Cms\Configuration\JinyaConfiguration;
use Jinya\Cms\Storage\StorageBaseService;
use Jinya\Cms\Utils\CacheUtils;
use Jinya\Cms\Web\Handlers\ErrorHandler;
use Jinya\Router\Extensions\JinyaDatabaseExtension;
use Nyholm\Psr7\Response;
require __DIR__ . '/defines.php';
require __DIR__ . '/vendor/autoload.php';
if (!is_dir(StorageBaseService::SAVE_PATH) && !mkdir(
$concurrentDirectory = StorageBaseService::SAVE_PATH,
0775,
true
) && !is_dir($concurrentDirectory)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
}
function getRouterConfiguration(): array
{
return [
__JINYA_CACHE,
__JINYA_CONTROLLERS,
new Response(404),
null,
new JinyaDatabaseExtension(
__JINYA_CACHE,
__JINYA_ENTITY,
new ErrorHandler()
)
];
}
JinyaConfiguration::getConfiguration()->reconfigureDatabase();
if (file_exists(__DIR__ . '/.env') || file_exists(__DIR__ . '/.env.dist')) {
$dotenv = Dotenv::createUnsafeImmutable(__DIR__, ['.env', '.env.dist']);
$dotenv->load();
}
JinyaConfiguration::getConfiguration()->reconfigureDatabase();
if (JinyaConfiguration::getConfiguration()->get('env', 'app', 'prod') === 'dev') {
CacheUtils::recreateRoutingCache();
}