forked from ifacesoft/ice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
64 lines (50 loc) · 1.77 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
<?php
if (defined('ICE_BOOTSTRAP')) {
return;
}
define('ICE_BOOTSTRAP', true);
if (!defined('ICE_DIR')) {
define('ICE_DIR', __DIR__ . '/');
}
if (!defined('MODULE_DIR')) {
$moduleDir = php_sapi_name() == 'cli'
// ? dirname(realpath($_SERVER['argv'][0]))
? getcwd()
: dirname(dirname($_SERVER['SCRIPT_FILENAME']));
if (file_exists($moduleDir . '/app.php')) {
define('MODULE_DIR', $moduleDir . '/');
} else {
define('MODULE_DIR', ICE_DIR);
}
}
if (!defined('VENDOR_DIR')) {
define('VENDOR_DIR', MODULE_DIR . 'Var/vendor/');
}
if (!defined('MODULE_CONFIG_PATH')) {
define('MODULE_CONFIG_PATH', 'Config/Ice/Core/Module.php');
}
global $loader;
if (!$loader) {
$loader = require VENDOR_DIR . 'autoload.php';
}
try {
$config = require MODULE_DIR . MODULE_CONFIG_PATH;
foreach($config['module']['ignorePatterns'] as $ignorePattern) {
if (preg_match($ignorePattern, \Ice\Core\Request::uri(true))) {
return;
}
}
require_once ICE_DIR . 'Source/Ice/Core/Data/Provider.php';
require_once ICE_DIR . 'Source/Ice/Data/Provider/File.php';
require_once ICE_DIR . 'Source/Ice/Data/Provider/Apc.php';
require_once ICE_DIR . 'Source/Ice/Data/Provider/Redis.php';
require_once ICE_DIR . 'Source/Ice/Core/View/Render.php';
require_once ICE_DIR . 'Source/Ice/Helper/Api/Client/Yandex/Translate.php';
\Ice\Core\Bootstrap::getInstance($config['module']['bootstrapClass'])->init($loader);
} catch (Exception $e) {
echo '<span style="font-weight: bold;">Bootstrapping failed: ' .
str_replace(MODULE_DIR, '', $e->getMessage()) .
'</span><br>';
echo nl2br(str_replace(MODULE_DIR, '', $e->getTraceAsString()));
die('Terminated. Bye-bye...' . "\n");
}