/** * Initializes the framework. This can only be called once. * * @access public * @return void */ public static function init($config) { if (static::$initialized) { throw new \Fuel_Exception("You can't initialize Fuel more than once."); } register_shutdown_function('fuel_shutdown_handler'); set_exception_handler('fuel_exception_handler'); set_error_handler('fuel_error_handler'); // Start up output buffering ob_start(); static::$profiling = isset($config['profiling']) ? $config['profiling'] : false; if (static::$profiling) { \Profiler::init(); \Profiler::mark(__METHOD__ . ' Start'); } static::$cache_dir = isset($config['cache_dir']) ? $config['cache_dir'] : APPPATH . 'cache/'; static::$caching = isset($config['caching']) ? $config['caching'] : false; static::$cache_lifetime = isset($config['cache_lifetime']) ? $config['cache_lifetime'] : 3600; if (static::$caching) { static::$path_cache = static::cache('Fuel::path_cache'); } \Config::load($config); static::$_paths = array(APPPATH, COREPATH); // Load in the routes \Config::load('routes', true); \Router::add(\Config::get('routes')); \View::$auto_encode = \Config::get('security.auto_encode_view_data'); if (!static::$is_cli) { if (\Config::get('base_url') === null) { \Config::set('base_url', static::generate_base_url()); } \Uri::detect(); } // Run Input Filtering \Security::clean_input(); static::$env = \Config::get('environment'); static::$locale = \Config::get('locale'); //Load in the packages foreach (\Config::get('always_load.packages', array()) as $package) { static::add_package($package); } // Set some server options setlocale(LC_ALL, static::$locale); // Always load classes, config & language set in always_load.php config static::always_load(); static::$initialized = true; if (static::$profiling) { \Profiler::mark(__METHOD__ . ' End'); } }