$this->serverRequestFactory =
$serverRequestFactory;
$this->streamFactory =
$streamFactory;
$this->uploadedFileFactory =
$uploadedFileFactory;
$this->responseFactory =
$responseFactory;
} public function createRequest(Request
$symfonyRequest): ServerRequestInterface
{ $uri =
$symfonyRequest->server->
get('QUERY_STRING', ''
);
$uri =
$symfonyRequest->
getSchemeAndHttpHost().
$symfonyRequest->
getBaseUrl().
$symfonyRequest->
getPathInfo().
('' !==
$uri ? '?'.
$uri : ''
);
$request =
$this->serverRequestFactory->
createServerRequest( $symfonyRequest->
getMethod(),
$uri,
$symfonyRequest->server->
all() );
foreach ($symfonyRequest->headers->
all() as $name =>
$value) { try { $request =
$request->
withHeader($name,
$value);
} catch (\InvalidArgumentException
$e) { // ignore invalid header
} }