public function register(Application $app) { $app->singleton('session', function () use($app) { /** @var SessionHandler $handler */ $handler = null; $container = $app->getContainer(); if ($container->exists('session.handler')) { $handler = $container->make('session.handler'); } return new Session(new NativeSessionStorage($app->getParameter('session.options', []), $handler)); }); }