Ejemplo n.º 1
0
 * @package   SyDES
 * @copyright 2011-2016, ArtyGrand <artygrand.ru>
 * @license   GNU GPL v3 or later; see LICENSE
 */
session_start();
mb_internal_encoding('UTF-8');
if (!isset($_SESSION['csrf_token'])) {
    $_SESSION['csrf_token'] = token(16);
}
$app = App\App::getInstance();
$handler = new App\Exception\Handler();
$app['exception_handler'] = function () {
    return new App\Exception\ExceptionHandler();
};
$app['request'] = function () {
    return App\Http\Request::capture();
};
$app['cache'] = function () {
    return new App\Cache(DIR_CACHE);
};
$app['translator'] = function () {
    return new App\Translator();
};
$app['event'] = function () {
    return new App\Event();
};
$app['section'] = strpos($app['request']->url, ADMIN) == 1 ? 'admin' : 'front';
$app['renderer'] = function ($c) {
    return $c['section'] == 'admin' ? new App\Renderer\Admin() : new App\Renderer\Front();
};
include DIR_SYSTEM . '/libraries/HTML.php';
Ejemplo n.º 2
0
    }
    // ʹÓÃÖ¸¶¨µÄÊý¾Ý¿â
    if (isset($opts['database'])) {
        $redis->select($opts['database']);
    }
    return $redis;
};
$container['cache'] = function () {
    return new \Slim\HttpCache\CacheProvider();
};
$container['response'] = function ($c) {
    $response = new App\Http\Response();
    return $response->withProtocolVersion($c->get('settings')['httpVersion']);
};
$container['request'] = function ($c) {
    return App\Http\Request::createFromEnvironment($c->get('environment'));
};
$container['errorHandler'] = function ($c) {
    return new App\Model\ErrorHandler($c->get('settings')['displayErrorDetails']);
};
$container['notFoundHandler'] = function ($c) {
    return function ($req, $res) {
        return $res->error(404, 'Not Found', 404);
    };
};
$container['notAllowedHandler'] = function ($c) {
    return function ($req, $res) {
        return $res->error(405, 'Method Not Allowed', 405);
    };
};
//Ç©ÃûÑéÖ¤ÃØÔ¿