/
init.php
79 lines (67 loc) · 1.78 KB
/
init.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
<?php
/**
* Gateway to initializing the Sleepy client framework.
*
* Sleepy, the lightweight web application framework.
* Copyright 2012 - 2014, Alex Palaistras (http://deuill.org)
*
* @copyright Copyright 2012 - 2014, Alex Palaistras (http://deuill.org)
* @link http://deuill.org/sleepy
* @package Sleepy.Core
* @since Sleepy 0.1.0
*/
/*
* Define directories used system-wide.
*
*/
define('CLIENT_DIR', __DIR__.'/');
define('CORE_DIR', CLIENT_DIR.'core/');
define('CONF_DIR', CLIENT_DIR.'config/');
define('MODULE_DIR', CLIENT_DIR.'modules/');
/*
* Include base files.
*
*/
require(CORE_DIR.'Sleepy.php');
require(CONF_DIR.'config.php');
Sleepy::load('Dispatcher', 'core');
Sleepy::load('Exceptions', 'core');
Sleepy::load('Inflector', 'core');
Sleepy::load('Mediator', 'core');
Sleepy::load('Router', 'core');
/*
* Load global configuration.
*
*/
Sleepy::set($config);
/*
* Prepare the environment.
*
*/
// Connect to server.
Sleepy::connect(
Sleepy::get('server', 'address'),
Sleepy::get('server', 'port')
);
// Set up error reporting depending on the environment.
switch (Sleepy::get('client', 'environment')) {
// Same as development below, only ignore fatal errors.
case 'testing':
Sleepy::set('client', 'show-errors', false);
// Show all errors and warnings.
case 'development':
error_reporting(-1);
ini_set('display_errors', 1);
break;
// Don't show PHP warnings and errors.
case 'production':
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
ini_set('display_errors', 0);
break;
default:
Exceptions::log("The 'client.environment' option has not been set correctly!");
Exceptions::error();
}
// PHP errors are handled by the application.
set_error_handler('Exceptions::handler');
/* End of file init.php */