このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
slim:4:request [2020/10/03 13:23] y2sunlight [Uploaded Files] |
slim:4:request [2020/10/07 21:19] y2sunlight |
||
---|---|---|---|
行 1: | 行 1: | ||
- | > 編集中 | ||
- | |||
- | ---- | ||
- | |||
====== Slim4 リクエスト ====== | ====== Slim4 リクエスト ====== | ||
Version 4.5.0 | Version 4.5.0 | ||
- | --- // | + | --- // |
[[slim: | [[slim: | ||
行 18: | 行 14: | ||
* [[slim: | * [[slim: | ||
* [[slim: | * [[slim: | ||
+ | * [[slim: | ||
本章は以下のサイトの **The Request** のセクションを翻訳し若干の補足を加えたのもです。 | 本章は以下のサイトの **The Request** のセクションを翻訳し若干の補足を加えたのもです。 | ||
行 260: | 行 257: | ||
\\ | \\ | ||
- | ===== Uploaded Files ===== | + | ===== アップロードファイル |
'' | '' | ||
行 267: | 行 264: | ||
$files = $request-> | $files = $request-> | ||
</ | </ | ||
- | |||
- | Each object in the '' | ||
'' | '' | ||
行 278: | 行 273: | ||
* getClientFilename() | * getClientFilename() | ||
* getClientMediaType() | * getClientMediaType() | ||
- | |||
- | See the cookbook on how to upload files using a POST form. | ||
POSTフォームを使用してファイルをアップロードする方法については、[[https:// | POSTフォームを使用してファイルをアップロードする方法については、[[https:// | ||
行 287: | 行 280: | ||
- | ===== Request Helpers | + | ===== リクエストヘルパー |
- | Slim’s PSR-7 Request implementation provides these additional proprietary methods to help you further inspect the HTTP request. | + | SlimのPSR-7リクエストの実装は、以下の追加の独自メソッドを提供し、HTTPリクエストをさらに検査するのを助けます。 |
- | SlimのPSR-7リクエストの実装は、HTTPリクエストをさらに検査するのに役立つ、これらの追加の独自のメソッドを提供します。 | + | ==== XHRリクエストの検出 ==== |
- | ==== Detect | + | リクエストの '' |
- | You can detect | + | >XHRとはXMLHttpRequestの略で、JavaScriptなどのからサーバとHTTP通信を行うためのAjaxで使われる組み込みオブジェクトの事です。 |
- | + | ||
- | リクエストの '' | + | |
< | < | ||
行 317: | 行 308: | ||
\\ | \\ | ||
- | ==== Content Type ==== | + | ==== コンテンツタイプ |
- | + | ||
- | You can fetch the HTTP request content type with the Request object’s '' | + | |
Requestオブジェクトの '' | Requestオブジェクトの '' | ||
行 329: | 行 318: | ||
\\ | \\ | ||
- | ==== Content Length | + | ==== コンテンツの長さ |
- | + | ||
- | You can fetch the HTTP request content length with the Request object’s '' | + | |
Requestオブジェクトの '' | Requestオブジェクトの '' | ||
行 341: | 行 328: | ||
\\ | \\ | ||
- | ==== Server Parameter | + | ==== サーバーパラメータ |
- | + | ||
- | To fetch data related to the incoming request environment, | + | |
- | + | ||
- | For example, to get a single Server Parameter: | + | |
- | 着信要求環境に関連するデータをフェッチするには、'' | + | 着信リクエストの環境に関連するデータをフェッチするには、'' |
- | たとえば、単一のサーバーパラメータを取得するには: | + | 例えば、単一のサーバーパラメータを取得するには: |
<code php> | <code php> | ||
行 358: | 行 341: | ||
\\ | \\ | ||
- | ==== POST Parameters | + | ==== ポストパラメータ |
- | If the request method is '' | + | you can retrieve all '' |
- | リクエストメソッドが '' | + | リクエストメソッドが '' |
<code php> | <code php> | ||
行 374: | 行 357: | ||
\\ | \\ | ||
- | ===== Route Object | + | ===== ルートオブジェクト===== |
- | Sometimes in middleware you require the parameter of your route. | + | ミドルウェアでは、ルート(route)のパラメータが必要になる場合があります。 |
- | + | ||
- | In this example we are checking first that the user is logged in and second that the user has permissions to view the particular video they are attempting to view. | + | |
- | + | ||
- | ミドルウェアでは、ルートのパラメータが必要になる場合があります。 | + | |
この例では、最初にユーザーがログインしていることを確認し、次にユーザーが表示しようとしている特定のビデオを表示する権限を持っていることを確認しています。 | この例では、最初にユーザーがログインしていることを確認し、次にユーザーが表示しようとしている特定のビデオを表示する権限を持っていることを確認しています。 | ||
行 415: | 行 394: | ||
\\ | \\ | ||
- | ===== Obtain Base Path From Within Route ===== | + | ===== ルート内からベースパスを取得する |
- | + | ||
- | To obtain the base path from within a route simply do the following: | + | |
ルート内からベースパスを取得するには、次の手順を実行します: | ルート内からベースパスを取得するには、次の手順を実行します: | ||
行 444: | 行 421: | ||
\\ | \\ | ||
- | ===== Attributes | + | ===== 属性 |
- | With PSR-7 it is possible to inject objects/values into the request object for further processing. In your applications middleware often need to pass along information to your route closure and the way to do it is to add it to the request object via an attribute. | + | PSR-7を使用すると、さらに処理するために、オブジェクト/値をリクエストオブジェクトに注入することができます。アプリケーションでは、ミドルウェアは多くの場合、ルート(route)クロージャーに情報を渡す必要があります。そのための方法は、属性を介してリクエストオブジェクトに情報を追加することです。 |
- | Example, Setting a value on your request object. | + | 例:リクエストオブジェクトに値を設定します。 |
- | + | ||
- | PSR-7を使用すると、オブジェクト/ | + | |
- | + | ||
- | 例、リクエストオブジェクトに値を設定します。 | + | |
<code php> | <code php> | ||
行 466: | 行 439: | ||
</ | </ | ||
- | Example, how to retrieve the value. | + | 例:値を取得する方法です。 |
- | + | ||
- | 例、値を取得する方法。 | + | |
<code php> | <code php> | ||
行 484: | 行 455: | ||
</ | </ | ||
- | The request object also has bulk functions as well. $request-> | + | リクエストオブジェクトには、'' |
- | + | ||
- | リクエストオブジェクトには、'' | + | |
\\ | \\ | ||