-
Notifications
You must be signed in to change notification settings - Fork 44
/
bootstrap.php
84 lines (77 loc) · 2.49 KB
/
bootstrap.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
//Check if autoload has been already loaded (in case plugin installed in existing project)
use TelegramRSS\Logger;
$root = __DIR__;
if (!class_exists('TelegramRSS')) {
if (!file_exists($root . '/vendor/autoload.php')) {
$root = __DIR__ . '/../../..';
}
if (!file_exists($root . '/vendor/autoload.php')) {
system('composer install -o --no-dev');
$root = __DIR__;
}
require_once $root . '/vendor/autoload.php';
chdir($root);
}
define('ROOT_DIR', $root);
$envPath = '.env';
if ($options['docker']) {
$envPath .= '.docker';
}
$envPathExample = $envPath . '.example';
if (!is_file($envPath) || filesize($envPath) === 0) {
echo "No {$envPath} file found. Making copy of {$envPathExample} \r";
//Dont use copy because of docker symlinks
$envContent = file_get_contents($envPathExample);
file_put_contents($envPath, $envContent);
}
//Check if root env file hash been loaded (in case plugin installed in existing project)
if (!getenv('SERVER_ADDRESS')) {
Dotenv\Dotenv::createUnsafeImmutable($root, $envPath)->load();
}
if ($memoryLimit = getenv('MEMORY_LIMIT')) {
ini_set('memory_limit', $memoryLimit);
}
if ($timezone = getenv('TIMEZONE')) {
date_default_timezone_set($timezone);
}
if (!function_exists('debug')) {
function debug(string $message, array $context) {
Logger::getInstance()->debug($message, $context);
}
}
if (!function_exists('info')) {
function info(string $message, array $context = []) {
Logger::getInstance()->info($message, $context);
}
}
if (!function_exists('notice')) {
function notice($message, array $context = []) {
Logger::getInstance()->notice($message, $context);
}
}
if (!function_exists('warning')) {
function warning(string $message, array $context = []) {
Logger::getInstance()->warning($message, $context);
}
}
if (!function_exists('error')) {
function error(string $message, array $context = []) {
Logger::getInstance()->error($message, $context);
}
}
if (!function_exists('critical')) {
function critical(string $message, array $context = []) {
Logger::getInstance()->critical($message, $context);
}
}
if (!function_exists('alert')) {
function alert(string $message, array $context = []) {
Logger::getInstance()->alert($message, $context);
}
}
if (!function_exists('emergency')) {
function emergency(string $message, array $context = []) {
Logger::getInstance()->emergency($message, $context);
}
}