このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| 
                    slim:4:concepts [2020/10/02 13:59] 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:// | 
| - | Slimは、オプションの依存関係コンテナーを使用して、アプリケーションの依存関係を準備、管理、および挿入します。 Slimは、PHP-DIのようなPSR-11を実装するコンテナーをサポートします。 | + | > PSR-11の邦訳は[[psr: | 
| - | ==== Example usage with PHP-DI ==== | + | |
| - | 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> | ||
| 行 437: | 行 444: | ||
| </ | </ | ||
| - | Add a service to your container: | + | そして、コンテナにサービスを追加します: | 
| <code php> | <code php> | ||
| 行 446: | 行 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> | ||
| 行 467: | 行 474: | ||
| </ | </ | ||
| - | To test if a service exists in the container before using it, use the '' | + | コンテナを使用する前にサービスがコンテナに存在するかどうかをテストするには、次のように  | 
| <code php> | <code php> | ||
| 行 489: | 行 496: | ||
| \\ | \\ | ||
| - | ==== Configuring the application via a container  | + | ==== コンテナを介したアプリケーションの構成  | 
| - | In case you want to create the '' | + | コンテナに依存性が既に定義されている  | 
| - | **Example** | + | **例題** | 
| <code php> | <code php> | ||
| 行 522: | 行 529: | ||
| </ | </ | ||
| - | Supported App dependencies are: | + | サポートされているアプリの依存関係は次のとおりです: | 
| * Psr\Http\Message\ResponseFactoryInterface | * Psr\Http\Message\ResponseFactoryInterface | ||