/
lithium.php
59 lines (48 loc) · 1.66 KB
/
lithium.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
<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
namespace lithium;
use lithium\core\Libraries;
use lithium\console\Dispatcher;
/**
* Determine if we're in an application context by moving up the directory tree looking for
* a `config` directory with a `bootstrap.php` file in it. If no application context is found,
* just boot up the core framework.
*/
$library = dirname(dirname(__DIR__));
$working = getcwd() ?: __DIR__;
$app = null;
while (!$app && $working) {
if (file_exists($working . '/config/bootstrap.php')) {
$app = $working;
} elseif (file_exists($working . '/app/config/bootstrap.php')) {
$app = $working . '/app';
} else {
$working = ($parent = dirname($working)) != $working ? $parent : false;
}
}
if ($app && is_dir("{$app}/config/bootstrap") && file_exists("{$app}/webroot/index.php")) {
include "{$app}/config/bootstrap.php";
exit(Dispatcher::run()->status);
}
define('LITHIUM_LIBRARY_PATH', $library);
define('LITHIUM_APP_PATH', $app ? $working : dirname($library) . '/app');
if (!include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php') {
$message = "Lithium core could not be found. Check the value of `LITHIUM_LIBRARY_PATH` ";
$message .= "in `config/bootstrap.php`. It should point to the directory containing your ";
$message .= "`/libraries` directory.";
trigger_error($message, E_USER_ERROR);
}
Libraries::add('lithium');
if ($app) {
Libraries::add(basename(LITHIUM_APP_PATH), array(
'path' => LITHIUM_APP_PATH,
'default' => true
));
}
exit(Dispatcher::run()->status);
?>