// Start native session to get a session id for the Laravel session store and // filesystem session handler session_name('slim-boilerplate'); session_start(); // Environment based configuration // Allows developers using the getenv('<name>') method to fetch configuration values if (file_exists(__BASE_DIR . '.env')) { Dotenv::load(__BASE_DIR); } // IoC container setup $container = new \Illuminate\Container\Container(); // Application configuration $config = (include __BASE_DIR . 'app/config/config.php'); $config = new \App\Components\Config\Config($config); $container->instance('\\App\\Components\\Config\\Config', $config); $container->alias('\\App\\Components\\Config\\Config', 'config'); // Slim application setup $container->singleton('Slim\\Slim', function ($container) use($config) { $app = new \Slim\Slim(array('debug' => $config->get('app.debug'), 'mode' => $config->get('app.mode'), 'log.enabled' => $config->get('app.logging.enabled'), 'log.level' => $config->get('app.logging.level'), 'log.writer' => new \App\Components\Logging\FileSystemLogWriter(__BASE_DIR . 'app/storage/logs/' . date('ymd') . '.log'), 'templates.path' => __BASE_DIR . 'app/ressources/views', 'view' => new \Slim\Views\Twig())); // Twig template engine setup $app->view()->parserOptions = array('debug' => $config->get('app.debug'), 'cache' => __BASE_DIR . 'app/storage/cache/views'); $app->view()->parserExtensions = array(new \Slim\Views\TwigExtension()); // Laravel session component start and shutdown configuration $app->hook('slim.before', function ($container) use($container) { $container->make('session')->start(); }); $app->hook('slim.after.router', function ($container) use($container) { $container->make('session')->save(); }); return $app; });