forked from xtrime-ru/TelegramRSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
41 lines (36 loc) · 1.21 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
<?php
//Check if autoload has been already loaded (in case plugin installed in existing project)
$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('SWOOLE_SERVER_ADDRESS')) {
Dotenv\Dotenv::createImmutable($root, $envPath)->load();
}
if ($memoryLimit = getenv('MEMORY_LIMIT')) {
ini_set('memory_limit', $memoryLimit);
}
if ($timezone = getenv('TIMEZONE')) {
date_default_timezone_set($timezone);
}