Esempio n. 1
0
<?php

/**
 * Application Bootstrap
 */
// Define your custom logic to retrieve the current APP_ENV
if (strrpos($_SERVER['HTTP_HOST'], '.local') === 0) {
    define('APP_ENV', 'development');
} else {
    if (strpos($_SERVER['HTTP_HOST'], 'stage.') === 0) {
        define('APP_ENV', 'staging');
    } else {
        define('APP_ENV', 'production');
    }
}
// Load environment-specific config
Options::loadPHP(APP_DIR . '/configs/' . APP_ENV . '.php');
Esempio n. 2
0
<?php

/**
 * Front Controller
 */
define('APP_DIR', dirname(__DIR__));
define('APP_MODE_CLI', false);
require APP_DIR . '/vendor/autoload.php';
$_response_send = new Deferred(function () {
    Response::sent() || Response::send();
});
// Load Classes
Loader::addPath(APP_DIR . '/classes');
// Load options
Options::loadPHP(APP_DIR . '/config.php');
// Temp directory
define('TEMP_DIR', Options::get('cache.directory', sys_get_temp_dir()));
// Caching strategy
Cache::using(['files' => ['cache_dir' => TEMP_DIR]]);
// Init Views
View::using(new View\Twig(APP_DIR . '/templates', ['cache' => Options::get('cache.views', true) ? TEMP_DIR : false, 'auto_reload' => Options::get('debug', false)]));
View::addGlobals(['BASE_URL' => rtrim(dirname($_SERVER['PHP_SELF']), '/') . '/', 'CACHEBUST' => Options::get('debug', false) ? '?v=' . time() : '']);
// App bootstrap
include APP_DIR . '/boot.php';
Event::trigger('app.run');
// Routes
foreach (glob(APP_DIR . '/routes/*.php') as $routedef) {
    include $routedef;
}
Event::trigger('app.dispatch');
Route::dispatch();