예제 #1
0
 public static function connect()
 {
     WFELoader::load("core/libs/redbean/rb.php");
     WFELoader::load("core/libs/QueryBuilder/QueryBuilder.php");
     $host = WFEConfig::get('db::host');
     $name = WFEConfig::get('db::name');
     $user = WFEConfig::get('db::user');
     $password = WFEConfig::get('db::password');
     $dbEnabled = WFEConfig::get('db::enabled');
     if ($dbEnabled == true) {
         R::setup('mysql:host=' . $host . '; dbname=' . $name, $user, $password);
     }
 }
예제 #2
0
// set exception handler
set_exception_handler(function (Exception $e) {
    if (WFEConfig::get('env') == 'dev') {
        exit($e->getMessage());
    } elseif (WFEConfig::get('env') == 'prod') {
        $response = WFERouter::run(new WFERequest('GET', 'WFE500'));
        $response->send();
    }
});
// Register autoload
WFEAutoload::register(__NAMESPACE__);
// Load main config
WFELoader::load('app/config/config.php');
// Load Database
\core\ORM\WFEDb::connect();
// Load smarty
WFELoader::load('core/libs/smarty/Smarty.class.php');
// set environment spec
if (WFEConfig::get('env') == 'dev') {
    error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_ALL);
} elseif (WFEConfig::get('env') == 'prod') {
    error_reporting(0);
} else {
    throw new WFEDefinitionException('Config settings env is not set properly (must be dev or prod)');
}
// init session
WFEsession::init();
// init request data
$request = new WFERequest();
// Routes request and get response
WFERouter::run($request);