<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Dependency Container Slim uses a dependency container to prepare, manage, and inject application dependencies. Slim supports containers that implement the?[Container-Interop](https://github.com/container-interop/container-interop)?interface. You can use Slim’s built-in container (based on?[Pimple](http://pimple.sensiolabs.org/)) or third-party containers like?[Acclimate](https://github.com/jeremeamia/acclimate-container)?or?[PHP-DI](http://php-di.org/). ## How to use the container You don’t?*have*?to provide a dependency container. If you do, however, you must inject the container instance into the Slim application’s constructor. ~~~ $container = new \Slim\Container; $app = new \Slim\App($container); ~~~ You can fetch services from your container explicitly or implicitly. You can fetch an explicit reference to the container instance from inside a Slim application route like this: ~~~ /** * Example GET route * * @param \Psr\Http\Message\ServerRequestInterface $req PSR7 request * @param \Psr\Http\Message\ResponseInterface $res PSR7 response * @param array $args Route parameters * * @return \Psr\Http\Message\ResponseInterface */ $app->get('/foo', function ($req, $res, $args) { $container = $this->getContainer(); $myService = $container->get('myService'); return $res; }); ~~~ You can implicitly fetch services from the container like this: ~~~ /** * Example GET route * * @param \Psr\Http\Message\ServerRequestInterface $req PSR7 request * @param \Psr\Http\Message\ResponseInterface $res PSR7 response * @param array $args Route parameters * * @return \Psr\Http\Message\ResponseInterface */ $app->get('/foo', function ($req, $res, $args) { $myService = $this->myService; return $res; }); ~~~ Slim uses?`__get()`?and?`__isset()`?magic methods that defer to the application’s container for all properties that do not already exist on the application instance. ## Required services Your container MUST implement these required services. If you use Slim’s built-in container, these are provided for you. If you choose a third-party container, you must define these required services on your own. ### settings Associative array of application settings, including keys?`httpVersion`,?`outputBuffering`,`responseChunkSize`?and?`determineRouteBeforeAppMiddleware`. ### environment Instance of?`\Slim\Interfaces\Http\EnvironmentInterface`. ### request Instance of?`\Psr\Http\Message\ServerRequestInterface`. ### response Instance of?`\Psr\Http\Message\ResponseInterface`. ### router Instance of?`\Slim\Interfaces\RouterInterface`. ### foundHandler Instance of?`\Slim\Interfaces\InvocationStrategyInterface`. ### errorHandler Callable invoked if application error. The callable?MUST?return an instance of`\Psr\Http\Message\ResponseInterface`?and accept three arguments: 1. `\Psr\Http\Message\ServerRequestInterface` 2. `\Psr\Http\Message\ResponseInterface` 3. `\Exception` ### notFoundHandler Callable invoked if the current HTTP request URI does not match an application route. The callable?MUST?return an instance of?`\Psr\Http\Message\ResponseInterface`?and accept two arguments: 1. `\Psr\Http\Message\ServerRequestInterface` 2. `\Psr\Http\Message\ResponseInterface` ### notAllowedHandler Callable invoked if an application route matches the current HTTP request path but not its method. The callable?MUST?return an instance of?`\Psr\Http\Message\ResponseInterface`and accept three arguments: 1. `\Psr\Http\Message\ServerRequestInterface` 2. `\Psr\Http\Message\ResponseInterface` 3. Array of allowed HTTP methods
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看