/** * {@inheritdoc} */ public function execute(ContainerInterface $app) { // @todo remove ErrorHandlerProvider // @todo add Error handler, and Whoops pretty when debug === true in Error Handler. $request = $app->get(ServerRequestFactory::class)->fromGlobals(); try { $response = $this->dispatch($app->get('router'), $request); $app->get(ResponseSender::class)->sendToGlobal($response); } catch (Exception $exception) { if ($exception instanceof HttpException) { $httpException = $exception; } else { // if not HttpException and debug mode, exception will be prettify(by Whoops). if ($app['config']->get('debug', true)) { throw $exception; } $httpException = new HttpException(); } $handler = $app['config']->get('error.handler'); if ($handler) { $response = $this->responsify($app->create($handler)->handle($request, $exception), $httpException); } else { $response = $httpException->toResponse(); } // body is '' if (!$response->getBody()) { $body = $response->getReasonPhrase(); $response = $response->withBody(new Stringstream($body)); } $app->get(ResponseSender::class)->sendToGlobal($response); } }
public function boot(ContainerInterface $app) { if ($app->has(KernelInterface::class)) { $kernel = $app->get(KernelInterface::class); $kernel['commands'] = (require __DIR__ . '/../app/commands.php'); $kernel['routes'] = (require __DIR__ . '/../app/routes.php'); } }
/** * {@inheritdoc} */ public function boot(ContainerInterface $app) { if ($app->has(KernelInterface::class)) { /** @var \Wandu\Foundation\Contracts\KernelInterface $kernel */ $kernel = $app->get(KernelInterface::class); $kernel['commands'] = ['psysh' => PsyshCommand::class, 'install' => InstallCommand::class]; } }
/** * @param \Wandu\DI\ContainerInterface $app * @return \Psr\Http\Message\ServerRequestInterface */ protected function createRequest(ContainerInterface $app) { return $this->request = $app->get(ServerRequestFactory::class)->createFromGlobals(); }
/** * {@inheritdoc} */ public function boot(ContainerInterface $app) { $app->get(DispatcherInterface::class)->setListeners($this->listeners); }
/** * {@inheritdoc} */ public function boot(ContainerInterface $app) { $app->get(Manager::class)->setAsGlobal(); $app->get(Manager::class)->bootEloquent(); }
public function equalSession(Session $session, SessionInterface $sessionInterface, ServerRequestInterface $request, ContainerInterface $container) { return $session === $sessionInterface && $session === $request->getAttribute('session') && $container->get('request') === $request && $container->get(ServerRequest::class) === $request && $container->get(ServerRequestInterface::class) === $request; }
public function boot(ContainerInterface $app) { $app->get('mockery')->boot(); }
/** * {@inheritdoc} */ public function execute(ContainerInterface $app) { $request = $app[ServerRequestFactory::class]->fromGlobals(); $method = strtoupper($request->getMethod()); if (!isset($this->routes[$method])) { throw new MethodNotAllowedException(); } $response = $this->routes[$method]->execute($app[ServerRequestFactory::class]->fromGlobals(), $app[ClassLoaderInterface::class]); $app->get(ResponseSender::class)->sendToGlobal($response); }