build(); $app = AppFactory::setContainer($container); // add middleware // add routes return $app; } /** * @param string $method * @param string path * @param array $headers * @param array $cookies * @param array $serverParams */ protected function createRequest( string $method, string $path, array $headers = [], array $cookies = [], array $serverParams = [] ): Request { $uri = new Uri('', '', 80, $path); $handle = fopen('php://temp', 'w+'); $stream = (new StreamFactory())->createStreamFromResource($handle); $h = new Headers(); foreach ($headers as $name => $value) { $h->addHeader($name, $value); } return new SlimRequest( $method, $uri, $h, $cookies, $serverParams, $stream ); } }