/** * Register the load events for the given provider. * * @param \Foundation\Application $app * @param string $provider * @param array $events * @return void */ protected function registerLoadEvents(Application $app, $provider, array $events) { if (count($events) < 1) { return; } $app->make('events')->listen($events, function () use($app, $provider) { $app->register($provider); }); }
use HTTP\Request; use HTTP\Session; use Routing\Router; require __DIR__ . '/../vendor/autoload.php'; $application = new Application(); $application->share('HTTP\\Session', function () { return new Session(); }); $application->share('i want to save to the session', function (Session $session) { $session->name = 'Reno Jackson'; $session->quotes = 'We\'re gonna be rich'; }); $application->share('i want to read the session', function (Session $session) { dump($session); }); $application->share('i want to flash to the session', function (Session $session) { // $session->flash->city = 'Nijmegen'; }); $application->share('i want to read the session flash', function (Session $session) { dump($session->flash); }); $router = new Router(); $router->add('/', 'i want to save to the session'); $router->add('/read', 'i want to read the session'); $router->add('/add/flash', 'i want to flash to the session'); $router->add('/read/flash', 'i want to read the session flash'); $kernel = new Kernel($router, $application); $response = $kernel->handle(Request::create('/read/flash')); $response->send(); $application->make('HTTP\\Session')->replenish(); dump($_SESSION);