public function boot($config = null, $log = null) { //overrides the default config folder if (!is_null($config)) { $config = realpath($config); if ($config !== false) { if (substr_compare($config, '/', -1, 1) != 0) { $config .= '/'; } define('__SP_CFG__', $config); } } //overrides the default log folder if (!is_null($log)) { $log = realpath($log); if ($log !== false) { if (substr_compare($log, '/', -1, 1) != 0) { $log .= '/'; } define('__SP_LOG__', $log); } } //defines the base path to framework define('__SAMPA__', dirname(dirname(__FILE__))); foreach (array('cfg', 'log', 'tpl') as $folder) { $key = '__SP_' . strtoupper($folder) . '__'; $path = realpath(__SAMPA__ . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR); if ($path === false) { $path = __SAMPA__; } if (!defined($key)) { define($key, $path . DIRECTORY_SEPARATOR); } } //loads the framework's configuration $this->config = Config::singleton(); $pos = strpos($_SERVER['REQUEST_URI'], '?'); if ($pos === false) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = substr($_SERVER['REQUEST_URI'], 0, $pos); } if ($this->config->set_app($_SERVER['HTTP_HOST'], $uri) === false) { throw new Exception\Boot('Application not found!'); } //sets locale setlocale(\LC_ALL, $this->config->read('framework/main/locale', 'en_US.UTF8')); //sets output and internal encoding $encoding = $this->config->read('framework/main/encoding', 'UTF-8'); mb_http_output($encoding); mb_internal_encoding($encoding); //sets the error display if ($this->config->read('framework/main/debug', true)) { ini_set('display_errors', 1); } else { ini_set('display_errors', 0); } error_reporting(-1); //sets the general error handler set_error_handler(array($this, 'logger')); //sets the proper include path for shared hosting $include = $this->config->read('framework/main/include_path', ''); if (!empty($include)) { set_include_path($include); } //sets the default timezone date_default_timezone_set($this->config->read('framework/main/timezone', 'UTC')); //loads the log handler $logfile = sprintf('%s%s-%s-kernel.log', __SP_LOG__, date('Ymd'), $this->config->read('framework/app/id', 'app')); $this->log = new Log($logfile, $this->config->read('framework/log/level', Log::DISABLED), $this->config->read('framework/log/buffered', true)); //creates basic response object $this->response = new Response($encoding, $this->config->read('framework/app/web_path', '/'), $this->config->read('framework/app/language', 'en-us')); $this->boot = true; }
public function boot($config = null, $log = null) { //overrides the default config folder if (!is_null($config)) { $config = realpath($config); if ($config !== false) { if (substr_compare($config, '/', -1, 1) != 0) { $config .= '/'; } define('__SP_CFG__', $config); } } //overrides the default log folder if (!is_null($log)) { $log = realpath($log); if ($log !== false) { if (substr_compare($log, '/', -1, 1) != 0) { $log .= '/'; } define('__SP_LOG__', $log); } } //defines the base path to framework define('__SAMPA__', dirname(dirname(__FILE__))); foreach (array('cfg', 'log', 'tpl') as $folder) { $key = '__SP_' . strtoupper($folder) . '__'; $path = realpath(__SAMPA__ . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR); if ($path === false) { $path = __SAMPA__; } if (!defined($key)) { define($key, $path . DIRECTORY_SEPARATOR); } } //loads the framework's configuration $this->config = Config::singleton(); //sets locale setlocale(\LC_ALL, $this->config->read('framework/main/locale', 'en_US.UTF8')); //sets output and internal encoding mb_internal_encoding($this->config->read('framework/main/encoding', 'UTF-8')); //sets the error display ini_set('display_errors', 1); error_reporting(E_ALL); //sets the proper include path for shared hosting $include = $this->config->read('framework/main/include_path', ''); if (!empty($include)) { set_include_path($include); } //sets the default timezone date_default_timezone_set($this->config->read('framework/main/timezone', 'UTC')); $this->boot = true; }