This repository was archived by the owner on May 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
69 lines (55 loc) · 1.64 KB
/
index.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
<?php
use Cyantree\Grout\App\App;
use Cyantree\Grout\App\Bootstrap;
use Cyantree\Grout\App\ConsoleBootstrap;
use Cyantree\Grout\AutoLoader;
// Catch startup error
$startupError = error_get_last();
while(ob_get_level()){
ob_end_clean();
}
$isConsole = php_sapi_name() == 'cli';
// Update configuration to fit your setup
$basePath = realpath(dirname(__FILE__)) . '/';
$init = array(
'frameworkPath' => $basePath,
'dataPath' => $basePath . 'data/',
'bootstrap' => array(
'module' => 'AppModule',
'config' => array(
'config' => null // Enter your desired configuration name
)
)
);
chdir($init['frameworkPath']);
// Init auto loader
require_once($init['frameworkPath'] . 'vendor/autoload.php');
AutoLoader::init();
if(is_dir('source/')){
AutoLoader::registerNamespace('', 'source/');
}
// Setup request and application
App::initEnvironment();
$app = new App();
$app->dataPath = $init['dataPath'];
if ($isConsole) {
$bootstrap = new ConsoleBootstrap($app);
$bootstrap->frameworkPath = $init['frameworkPath'];
$request = $bootstrap->init();
} else {
$bootstrap = new Bootstrap($app);
$bootstrap->frameworkPath = $init['frameworkPath'];
$bootstrap->usesModRewrite = true;
$bootstrap->checkForMagicQuotes = true;
$request = $bootstrap->init();
}
$request->config->set('startupError', $startupError);
$app->init();
// Import bootstrap module and process request
$app->importModule($init['bootstrap']['module'], null, $init['bootstrap']['config']);
$response = $app->processRequest($request);
$app->destroy();
if (!$isConsole) {
$response->postHeaders();
}
echo $response->content;