This module is used by Elephox to work with HTTP messages. It provides a range of features like parsing incoming HTTP messages, creating outgoing HTTP messages, parsing and modifying headers, cookies, query parameters, uploaded files, and URL parsing.
<?phpuseElephox\Http\ServerRequestBuilder;
useElephox\Http\Url;
useElephox\Http\Cookie;
useElephox\Http\Response;
useElephox\Http\ResponseCode;
useElephox\Http\ResponseSender;
useElephox\Http\UrlScheme;
$request = ServerRequestBuilder::fromGlobals();
$request->getUrl()->path; // '/requested/path'$newRequest = $request->with()
->header('X-Foo', 'bar')
->cookie(newCookie('dough', 'choco'))
->requestUrl(Url::fromString('https://example.com/new/url'))
->get();
$response = Response::build()
->responseCode(ResponseCode::OK)
->htmlBody('<h1>Hello World</h1>')
->header('X-Foo', 'bar')
->get();
ResponseSender::sendResponse($response); // you can also pass a response builder object here$url = Url::fromString('https://user@example.com/with/query?foo=bar&baz=qux');
$url->path; // '/with/query'$url->query; // ['foo' => 'bar', 'baz' => 'qux']$url->host; // 'example.com'$url->port; // null$url->scheme === UrlScheme::HTTPS; // true$url->scheme->getDefaultPort(); // 443$url->scheme->getScheme(); // 'https'$url->user; // 'user'$url->pass; // null$url->fragment; // null