public function __construct($settings = [])
{
$self = $this;
$this->registry = array_merge(['debug' => true, 'app.name' => 'LimeApp', 'session.name' => 'limeappsession', 'autoload' => new \ArrayObject([]), 'sec-key' => 'xxxxx-SiteSecKeyPleaseChangeMe-xxxxx', 'route' => isset($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : "/", 'charset' => 'UTF-8', 'helpers' => [], 'base_url' => implode("/", array_slice(explode("/", $_SERVER['SCRIPT_NAME']), 0, -1)), 'base_route' => implode("/", array_slice(explode("/", $_SERVER['SCRIPT_NAME']), 0, -1)), 'base_host' => isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : php_uname('n'), 'base_port' => isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80, 'docs_root' => null, 'site_url' => null], $settings);
// app modules container
$this->registry["modules"] = new \ArrayObject([]);
if (!isset($this["site_url"])) {
$this["site_url"] = $this->getSiteUrl(false);
}
if (!isset($this["docs_root"])) {
$this["docs_root"] = str_replace(DIRECTORY_SEPARATOR, '/', isset($_SERVER['DOCUMENT_ROOT']) ? realpath($_SERVER['DOCUMENT_ROOT']) : dirname($_SERVER['SCRIPT_FILENAME']));
}
// make sure base + route url doesn't end with a slash;
$this->registry["base_url"] = rtrim($this->registry["base_url"], '/');
$this->registry["base_route"] = rtrim($this->registry["base_route"], '/');
// default global viewvars
$this->viewvars["app"] = $this;
$this->viewvars["base_url"] = $this["base_url"];
$this->viewvars["base_route"] = $this["base_route"];
$this->viewvars["docs_root"] = $this["docs_root"];
self::$apps[$this["app.name"]] = $this;
// default helpers
$this->helpers = new \ArrayObject(array_merge(['session' => 'Lime\\Session', 'cache' => 'Lime\\Cache'], $this->registry["helpers"]));
// register simple autoloader
spl_autoload_register(function ($class) use($self) {
foreach ($self->retrieve("autoload", []) as $dir) {
$class_file = $dir . '/' . str_replace('\\', '/', $class) . '.php';
if (file_exists($class_file)) {
include_once $class_file;
return;
}
}
});
// check for php://input and merge with $_REQUEST
if (isset($_SERVER["CONTENT_TYPE"]) && stripos($_SERVER["CONTENT_TYPE"], 'application/json') !== false || isset($_SERVER["HTTP_CONTENT_TYPE"]) && stripos($_SERVER["HTTP_CONTENT_TYPE"], 'application/json') !== false) {
if ($json = json_decode(@file_get_contents('php://input'), true)) {
$_REQUEST = array_merge($_REQUEST, $json);
}
}
}