<?php

/**
 * Include necessary files, and setting class autoloader
 *
 * @copyright  Copyright 2014 - MidichlorianPHP and contributors
 * @author     NAYRAND Jérémie (dreadlokeur) <*****@*****.**>
 * @version    1.0.1dev2
 * @license    GNU General Public License 3 http://www.gnu.org/licenses/gpl.html
 * @package    MidichloriansPHP
 */
use MidiChloriansPHP\Autoloader;
// Checking
if (!version_compare(PHP_VERSION, '5.4.0', '>=')) {
    throw new \Exception('You must have at least PHP 5.4.0');
}
// Include neccesary files
require_once 'paths.php';
// Composer autoloader
require_once PATH_VENDOR . 'autoload.php';
// Autoloader configuration
$autoloader = new Autoloader();
$autoloader->setAutoloadExtensions(array('class.php', 'abstract.php', 'final.php', 'interface.php', 'trait.php', 'php'));
$autoloader->addNamespaces(array('libs' => PATH_LIBS, 'controllers' => PATH_CONTROLLERS, 'models' => PATH_MODELS));
// Include autoloaders adaptaters
$autoloader->registerAutoloaders(array('Includer' => array('prepend' => true), 'Cache' => array('prepend' => true), 'Finder' => array('prepend' => true)));
    throw new \Exception('Miss language path datas');
}
Language::setDatasPath(PATH_LANGUAGE);
$language = Language::getInstance();
if (!defined('LANGUAGE_DEFAULT')) {
    throw new \Exception('Miss language default');
}
$language->setLanguage(LANGUAGE_DEFAULT, true, true);
// Set default template
if (defined('TEMPLATE_DEFAULT')) {
    Template::setTemplate(TEMPLATE_DEFAULT);
}
//Enable debug tools
if (static::getDebug()) {
    $log->setLevel(Logger::DEBUG);
    Autoloader::setDebug(true);
    //Debug error and exeception
    $exc->attach(new Display());
    $err->attach(new Display());
}
// Logger parameters
if (defined('LOGGER_CACHE') && LOGGER_CACHE && !static::getDebug()) {
    $log->setCache(LOGGER_CACHE);
}
if (defined('LOGGER_LEVEL') && !static::getDebug()) {
    $log->setLevel(LOGGER_LEVEL);
}
if (defined('LOGGER_BACKTRACE') && LOGGER_BACKTRACE) {
    $log->setLogBackTrace(LOGGER_BACKTRACE);
}
if (defined('LOGGER_WRITE') && LOGGER_WRITE && !static::getDebug()) {