コード例 #1
0
ファイル: app.php プロジェクト: myurasov/spa-bootstrap
$app = new Application();
// service providers
$app->register(new DoctrineServiceProvider());
$app->register(new DoctrineOrmServiceProvider());
$app->register(new ServiceControllerServiceProvider());
$app->register(new TwigServiceProvider());
// configuration
$app['enviroment'] = (require __DIR__ . '/../../env.php');
require_once __DIR__ . '/config.prod.php';
require_once __DIR__ . '/config.' . $app['enviroment'] . '.php';
// services
// serialized response
$app['serialized_response'] = function () use($app) {
    $s = new SerializedResponse();
    $s->setFormat('json');
    $s->setCacheDir($app['serialized_response.cache_dir']);
    if ($app['debug']) {
        $s->setJsonOptions($s->getJsonOptions() | JSON_PRETTY_PRINT);
    }
    return $s;
};
// auth service
$app['auth'] = $app->share(function () use($app) {
    $auth = new DoctrineAuthService();
    $auth->setConnection($app['db']);
    return $auth;
});
// twig
$app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig) {
    // use custom tags to avoid conflicts with angular
    $lexer = new \Twig_Lexer($twig, array('tag_variable' => array('{{{', '}}}')));