<?php $startTime = microtime(true); require_once __DIR__ . '/../vendor/autoload.php'; // This is the default config. See `deploy_config/README.md' for more info. $config = array('debug' => true, 'timer.start' => $startTime, 'monolog.name' => 'silex-bootstrap', 'monolog.level' => \Monolog\Logger::DEBUG, 'monolog.logfile' => __DIR__ . '/log/app.log', 'twig.path' => __DIR__ . '/../src/App/views', 'twig.options' => array('cache' => __DIR__ . '/cache/twig')); // Apply custom config if available if (file_exists(__DIR__ . '/config.php')) { include __DIR__ . '/config.php'; } // Initialize Application $app = new App\Silex\Application($config); /** * Register controllers as services * @link http://silex.sensiolabs.org/doc/providers/service_controller.html **/ $app['app.default_controller'] = $app->share(function () use($app) { return new \App\Controller\DefaultController($app['twig'], $app['logger']); }); // Map routes to controllers include __DIR__ . '/routing.php'; return $app;
<?php $app = new App\Silex\Application(); (new Dotenv\Dotenv(__DIR__ . '/../'))->load(); $app['debug'] = true; $app['config'] = ['asset.files' => require __DIR__ . '/asset_files.php']; $app->register(new Silex\Provider\SessionServiceProvider()); $app['session.storage.options'] = ['name' => App\Constants::SESSION_NAME, 'cookie_lifetime' => App\Constants::SESSION_LIFETIME, 'cookie_httponly' => 1]; $app->register(new Silex\Provider\TwigServiceProvider(), ['twig.path' => __DIR__ . '/../views', 'twig.options' => ['debug' => true]]); $app['twig'] = $app->extend('twig', function ($twig, $app) { App\Silex\Util\TwigExtension::extend($twig, $app); return $twig; }); $app->register(new Silex\Provider\MonologServiceProvider(), ['monolog.logfile' => 'php://stderr', 'monolog.level' => Monolog\Logger::DEBUG, 'monolog.listener' => function () use($app) { return new App\Silex\EventListener\LogListener($app['logger']); }]); $app['params'] = function () use($app) { return new Silexcane\Silex\Service\Params($app); }; $app['messages'] = function () use($app) { return new Silexcane\Silex\Service\Messages($app); }; $app['csrf_token'] = function () use($app) { return new Silexcane\Silex\Service\CsrfToken($app); }; return $app;