-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
75 lines (60 loc) · 2.09 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
<?php
/**
* Do not edit this file. If you need to do any framework bootstrapping you should
* do it in the bootstrap.php file that lives within the application directory.
*/
namespace
{
include 'functions.php';
}
namespace Nerd
{
define('Nerd\LIBRARY_PATH', dirname(__DIR__));
define('Nerd\VENDOR_PATH', dirname(LIBRARY_PATH).DIRECTORY_SEPARATOR.'vendor');
define('Nerd\DOCROOT', dirname(LIBRARY_PATH).DIRECTORY_SEPARATOR.'public');
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
// Nerd Autoloader
import('nerd', 'Nerd', 'autoloader.php') and (new Autoloader())->register();
/**
* Test for CLI, load either application or Geek bootstrap.
*/
$application = PHP_SAPI === 'cli'
? import('geek', 'resolve.php')
: import('application', 'resolve.php');
$vars = $application();
/**
* Get and register the Composer autoloader as a secondary loader.
*/
$vendorLoader = import('..', 'vendor', 'autoload.php');
$vendorLoader->register();
/**
* Here you could do some magic for multiple applications by dynamically switching
* the application namespace for this request. To create another application you
* would simply create another subfolder in LIBRARY_PATH with its own Application
* class...
*/
define('Nerd\APPLICATION_NS', $vars['namespace']);
define('Nerd\STORAGE_PATH', join(DS, [LIBRARY_PATH, $vars['storage'], 'storage']));
/**
* Setup the current environment
*/
Environment::$active;
error_reporting(Config::get('error.reporting'));
ini_set('display_errors', (Config::get('error.display', true) ? 'On' : 'Off'));
date_default_timezone_set(Config::get('application.timezone', 'UTC'));
Str::$mbString and mb_internal_encoding(Config::get('application.encoding', 'UTF-8'));
/**
* Create and execute the application we need!
*/
$application = ucfirst(APPLICATION_NS).'\\Application';
$application = $application::instance();
$application->triggerEvent('application.startup');
if (property_exists($application, 'response')) {
$application->response->send(true);
} else {
$application->send();
}
$application->triggerEvent('application.shutdown');
}