このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
slim:4:concepts [2020/10/02 13:56] y2sunlight |
slim:4:concepts [2020/10/07 21:19] y2sunlight |
||
---|---|---|---|
行 1: | 行 1: | ||
- | ====== Slim4 のコンセプト ====== | + | ====== Slim4 コンセプト ====== |
Version 4.5.0 | Version 4.5.0 | ||
- | --- // | + | --- // |
[[slim: | [[slim: | ||
行 8: | 行 8: | ||
関連記事 | 関連記事 | ||
- | * [[slim: | + | * [[slim: |
- | * Slim4のコンセプト | + | * Slim4 コンセプト |
- | * [[slim:4:basic|Slim4の基本的な使い方]] | + | * [[slim:4:request|Slim4 |
+ | * [[slim: | ||
+ | * [[slim: | ||
+ | * [[slim: | ||
+ | * [[slim: | ||
- | 本章は以下のサイトの | + | 本章は以下のサイトの **Concepts** のセクションを翻訳し若干の補足を加えたのもです。 |
* https:// | * https:// | ||
行 413: | 行 417: | ||
===== 依存性コンテナ― ===== | ===== 依存性コンテナ― ===== | ||
- | Slim uses an optional dependency container to prepare, manage, and inject application dependencies. | + | Slimは、オプションの依存性コンテナーを使用して、アプリケーションの依存関係を準備、管理、および注入します。Slimは、[[https:// |
- | ==== Example usage with PHP-DI ==== | + | > PSR-11の邦訳は[[psr: |
- | You don’t have to provide a dependency container. If you do, however, you must provide an instance of the container to '' | + | \\ |
+ | |||
+ | ==== PHP-DIでの使用例 ==== | ||
+ | |||
+ | 依存関係コンテナを必ず提供する必要があるとは限りません。但し、そうする場合は、'' | ||
<code php> | <code php> | ||
行 436: | 行 444: | ||
</ | </ | ||
- | Add a service to your container: | + | そして、コンテナにサービスを追加します: |
<code php> | <code php> | ||
行 445: | 行 453: | ||
</ | </ | ||
- | You can fetch services from your container explicitly as well as from inside a Slim application route like this: | + | 次のように、明示的にコンテナからからだけでなく、Slimアプリケーションルートの内からサービスをフェッチできます: |
<code php> | <code php> | ||
行 466: | 行 474: | ||
</ | </ | ||
- | To test if a service exists in the container before using it, use the '' | + | コンテナを使用する前にサービスがコンテナに存在するかどうかをテストするには、次のように |
<code php> | <code php> | ||
行 488: | 行 496: | ||
\\ | \\ | ||
- | ==== Configuring the application via a container | + | ==== コンテナを介したアプリケーションの構成 |
- | In case you want to create the '' | + | コンテナに依存性が既に定義されている |
- | **Example** | + | **例題** |
<code php> | <code php> | ||
行 521: | 行 529: | ||
</ | </ | ||
- | Supported App dependencies are: | + | サポートされているアプリの依存関係は次のとおりです: |
* Psr\Http\Message\ResponseFactoryInterface | * Psr\Http\Message\ResponseFactoryInterface |