Naify\Psr\Contract\ServerRequestInterface インターフェース
サーバーリクエストインターフェース — PSR-7 ServerRequestInterface 相当
RequestInterface に加えて、$_SERVER / $_GET / $_POST / $_COOKIE / $_FILES といった Web 実行環境の情報を保持する。
使用例
$query = $request->getQueryParams();
$userId = $request->getAttribute('userId');
$request = $request->withAttribute('traceId', 'abc-123');
メソッド
| メソッド | 説明 |
|---|---|
public
getServerParams(): array
|
$_SERVER 相当のサーバーパラメータを返す |
public
getCookieParams(): array
|
$_COOKIE 相当のクッキーパラメータを返す |
public
withCookieParams(array $cookies): static
|
クッキーパラメータを差し替えた新インスタンスを返す |
public
getQueryParams(): array
|
$_GET 相当のクエリパラメータを返す |
public
withQueryParams(array $query): static
|
クエリパラメータを差し替えた新インスタンスを返す |
public
getUploadedFiles(): array
|
アップロードファイルの配列を返す |
public
withUploadedFiles(array $uploadedFiles): static
|
アップロードファイルを差し替えた新インスタンスを返す |
public
getParsedBody(): object|array|null
|
パース済みボディ ($_POST 等) を返す。未パースなら null |
public
withParsedBody(mixed $data): static
|
パース済みボディを差し替えた新インスタンスを返す |
public
getAttributes(): array
|
リクエスト属性の全配列を返す (ルーティング結果等) |
public
getAttribute(string $name, mixed $default): mixed
|
指定キーの属性を返す |
public
withAttribute(string $name, mixed $value): static
|
属性を追加した新インスタンスを返す |
public
withoutAttribute(string $name): static
|
属性を除去した新インスタンスを返す |
継承メソッド
| メソッド | 説明 | 継承元 |
|---|---|---|
public
getRequestTarget(): string
|
リクエストターゲット (パス + クエリ) を返す | RequestInterface |
public
withRequestTarget(): static
|
リクエストターゲットを差し替えた新インスタンスを返す | RequestInterface |
public
getMethod(): string
|
HTTP メソッド (GET, POST 等) を返す | RequestInterface |
public
withMethod(): static
|
HTTP メソッドを差し替えた新インスタンスを返す | RequestInterface |
public
getUri(): UriInterface
|
リクエスト URI を返す | RequestInterface |
public
withUri(): static
|
URI を差し替えた新インスタンスを返す | RequestInterface |
public
getProtocolVersion(): string
|
HTTP プロトコルバージョンを返す | MessageInterface |
public
withProtocolVersion(): static
|
HTTP プロトコルバージョンを変更した新しいインスタンスを返す | MessageInterface |
public
getHeaders(): array
|
すべてのヘッダーを返す | MessageInterface |
public
hasHeader(): bool
|
指定したヘッダーが存在するか判定する | MessageInterface |
public
getHeader(): array
|
指定したヘッダーの値一覧を返す | MessageInterface |
public
getHeaderLine(): string
|
指定したヘッダーを 1 行文字列として返す | MessageInterface |
public
withHeader(): static
|
ヘッダーを置き換えた新しいインスタンスを返す | MessageInterface |
public
withAddedHeader(): static
|
ヘッダー値を追加した新しいインスタンスを返す | MessageInterface |
public
withoutHeader(): static
|
指定したヘッダーを除外した新しいインスタンスを返す | MessageInterface |
public
getBody(): StreamInterface
|
メッセージボディのストリームを返す | MessageInterface |
public
withBody(): static
|
メッセージボディを差し替えた新しいインスタンスを返す | MessageInterface |