Ground Sunlight

Windowsで作る - PHPプログラミングの開発環境

ユーザ用ツール

サイト用ツール


サイドバー

メインメニュー

XAMPP アレンジ

IED

WSL2

道具箱

リポジトリ編

フレームワーク編

公開ソフトウェア

メタ
リンク


このページへのアクセス
今日: 6 / 昨日: 2
総計: 914

psr:psr17

文書の過去の版を表示しています。


編集中

PSR-17: HTTP Factories

y2sunlight 2020-07-28

本章は、若干の補足を加筆してはいるものの単にPSRのサイトを日本語に翻訳したものに過ぎません。英語が堪能な方は原文をご参照下さい。翻訳に当たっては、基本的に機械翻訳を使い、理解できない部分は独断で意訳しております。拙い訳では御座いますが恥を忍んで投稿しておりますので、ご指摘など御座いましたらコメントを頂ければ幸いです。

関連記事


PSR-17: HTTPファクトリー

原文より翻訳 PSR-17: HTTP HTTP Factories 2020-08-17 現在

This document describes a common standard for factories that create PSR-7 compliant HTTP objects.

このドキュメントでは、PSR-7準拠のHTTPオブジェクトを作成するファクトリーの一般的な規約について説明します。

PSR-7 did not include a recommendation on how to create HTTP objects, which leads to difficulties when needing to create new HTTP objects within components that are not tied to a specific implementation of PSR-7.

PSR-7には、HTTPオブジェクトの作成方法に関する推奨事項が含まれていなかったため、PSR-7の特定の実装に関連付けられていないコンポーネント内に新しいHTTPオブジェクトを作成する必要がある場合に問題が発生します。

The interfaces outlined in this document describe methods by which PSR-7 objects can be instantiated.

このドキュメントで概説されているインターフェースは、PSR-7オブジェクトをインスタンス化できるメソッドについて説明しています。

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

このドキュメントのキーワード MUST , MUST NOT , REQUIRED , SHALL , SHALL NOT , SHOULD , SHOULD NOT , RECOMMENDED , MAY 及び OPTIONAL は、 RFC 2119で説明されているように解釈して下さい。

RFC 2119の説明
MUST, REQUIRED, SHALL — 絶対必要
MUST NOT, SHALL NOT — 絶対禁止
SHOULD, RECOMMENDED — 推奨(但し、無視できる特定の正当な理由が存在するかもしれない)
SHOULD NOT — 推奨できない(但し、許可できる特定の正当な理由が存在するかもしれない)
MAY, OPTIONAL — オプション


1. 仕様

An HTTP factory is a method by which a new HTTP object, as defined by PSR-7, is created. HTTP factories MUST implement these interfaces for each object type that is provided by the package.

HTTPファクトリーは、PSR-7で定義されている新しいHTTPオブジェクトを作成するためのメソッドです。HTTPファクトリーは、パッケージによって提供されるそれぞれのオブジェクトタイプごとにこれらのインターフェースを実装する必要があります( MUST )。


2. インターフェース

The following interfaces MAY be implemented together within a single class or in separate classes.

以下のインターフェースは、単一のクラスまたは別々のクラスで一緒に実装される場合があります( MAY )。


2.1 RequestFactoryInterface

Has the ability to create client requests.

このインターフェースはクライアント要求を作成する機能があります。

RequestFactoryInterface.php
namespace Psr\Http\Message;
 
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UriInterface;
 
interface RequestFactoryInterface
{
    /**
     * Create a new request.
     * 新しいリクエストを作成します。
     *
     * @param string $method The HTTP method associated with the request.
     *                       リクエストに関連付けられたHTTPメソッド。
     * @param UriInterface|string $uri The URI associated with the request. 
     *                                 リクエストに関連付けられたURI。
     */
    public function createRequest(string $method, $uri): RequestInterface;
}


2.2 ResponseFactoryInterface

Has the ability to create responses.

このインターフェースは応答を作成する機能があります。

ResponseFactoryInterface.php
namespace Psr\Http\Message;
 
use Psr\Http\Message\ResponseInterface;
 
interface ResponseFactoryInterface
{
    /**
     * Create a new response.
     * 新しいレスポンスを作成します。
 
     *
     * @param int $code The HTTP status code. Defaults to 200.
     *                  HTTPステータスコード。デフォルトは200です。
     * @param string $reasonPhrase The reason phrase to associate with the status code
     *     in the generated response. If none is provided, implementations MAY use
     *     the defaults as suggested in the HTTP specification.
     *     生成された応答のステータスコードに関連付ける理由フレーズ。
     *     何も提供されていない場合、実装はHTTP仕様で提案されているデフォルトを使用できます。
     */
    public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface;
}


2.3 ServerRequestFactoryInterface

Has the ability to create server requests.

このインターフェースはサーバー要求を作成する機能があります。

ServerRequestFactoryInterface.php
namespace Psr\Http\Message;
 
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UriInterface;
 
interface ServerRequestFactoryInterface
{
    /**
     * Create a new server request.
     * 新しいサーバーリクエストを作成します。
     *
     * Note that server parameters are taken precisely as given - no parsing/processing
     * of the given values is performed. In particular, no attempt is made to
     * determine the HTTP method or URI, which must be provided explicitly.
     * サーバーパラメータは指定されたとおりに正確に取得されることに注意してください。
     * 指定された値の解析/処理は実行されません。特に、明示的に指定する必要があるHTTPメソッドまたは
     * URIを決定する試みは行われません。
     *
     * @param string $method The HTTP method associated with the request.
     *                       リクエストに関連付けられたHTTPメソッド。
     * @param UriInterface|string $uri The URI associated with the request. 
     *                                 リクエストに関連付けられたURI。
     * @param array $serverParams An array of Server API (SAPI) parameters with
     *     which to seed the generated request instance.
     *     生成されたリクエストのインスタンスをシードするサーバーAPI(SAPI)パラメーターの配列。
     */
    public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface;
}


2.4 StreamFactoryInterface

2.5 UploadedFileFactoryInterface

2.6 UriFactoryInterface

コメント

コメントを入力. Wiki文法が有効です:
 
psr/psr17.1597715496.txt.gz · 最終更新: 2020/08/18 10:51 by tanaka