get(self::class); return $application; } public function run(bool $isSetupPage = false): void { $requestHandler = new QueueRequestHandler(new ApplicationHandler($this)); $requestHandler->add(new ErrorHandling($this->errorHandler)); $requestHandler->add(new OutputBuffering()); $requestHandler->add(new PhpExtensionsChecking($this->template, $this->responseFactory)); $requestHandler->add(new ServerConfigurationChecking($this->template, $this->responseFactory)); $requestHandler->add(new PhpSettingsConfiguration()); $requestHandler->add(new RouteParsing()); $requestHandler->add(new ConfigLoading($this->config, $this->template, $this->responseFactory)); $requestHandler->add(new UriSchemeUpdating($this->config)); $requestHandler->add(new SessionHandling( $this->config, $this->errorHandler, $this->template, $this->responseFactory, )); $requestHandler->add(new EncryptedQueryParamsHandling()); $requestHandler->add(new UrlParamsSetting($this->config)); $requestHandler->add(new TokenRequestParamChecking()); $requestHandler->add(new DatabaseAndTableSetting()); $requestHandler->add(new SqlQueryGlobalSetting()); $requestHandler->add(new LanguageLoading()); $requestHandler->add(new ConfigErrorAndPermissionChecking( $this->config, $this->template, $this->responseFactory, )); $requestHandler->add(new RequestProblemChecking($this->template, $this->responseFactory)); $requestHandler->add(new CurrentServerGlobalSetting($this->config)); $requestHandler->add(new ThemeInitialization()); $requestHandler->add(new UrlRedirection($this->config, $this->template, $this->responseFactory)); $requestHandler->add(new SetupPageRedirection($this->config, $this->responseFactory)); $requestHandler->add(new MinimumCommonRedirection($this->config, $this->responseFactory)); $requestHandler->add(new LanguageAndThemeCookieSaving($this->config)); $requestHandler->add(new LoginCookieValiditySetting($this->config)); $requestHandler->add(new Authentication($this->config, $this->template, $this->responseFactory)); $requestHandler->add(new DatabaseServerVersionChecking($this->config, $this->template, $this->responseFactory)); $requestHandler->add(new SqlDelimiterSetting($this->config)); $requestHandler->add(new ResponseRendererLoading($this->config)); $requestHandler->add(new ProfilingChecking()); $requestHandler->add(new UserPreferencesLoading($this->config)); $requestHandler->add(new RecentTableHandling($this->config)); $requestHandler->add(new StatementHistory($this->config)); $runner = new RequestHandlerRunner( $requestHandler, new SapiEmitter(), static fn (): ServerRequestInterface => ServerRequestFactory::create() ->fromGlobals() ->withAttribute('isSetupPage', $isSetupPage), function (Throwable $throwable): ResponseInterface { $response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR); $response->getBody()->write(sprintf('An error occurred: %s', $throwable->getMessage())); return $response; }, ); $runner->run(); } public function handle(ServerRequest $request): Response { return Routing::callControllerForRoute( $request, Routing::getDispatcher(), ContainerBuilder::getContainer(), $this->responseFactory, ); } }