build(); // Instantiate the app AppFactory::setContainer($container); $app = AppFactory::create(); // Register middleware $middleware = require __DIR__ . '/../app/middleware.php'; $middleware($app); // Register routes $routes = require __DIR__ . '/../app/routes.php'; $routes($app); return $app; } /** * @param string $method * @param string $path * @param array $headers * @param array $cookies * @param array $serverParams * @return Request */ protected function createRequest( string $method, string $path, array $headers = ['HTTP_ACCEPT' => 'application/json'], 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); } }