<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 功能強大 支持多語言、二開方便! 廣告
                ## 容器和依賴注入 5.1正式引入了容器的概念,用來管理類依賴及運行依賴注入。 >[danger] 5.0版本已經支持依賴注入的,依賴注入和容器沒有直接關系,只是有時候還不夠方便而已 使用`app`助手函數獲取容器中的對象實例(支持依賴注入)。 ~~~ $app = app(); // 判斷對象實例是否存在 isset($app->cache); // 注冊容器對象實例 $app->cache = think\Cache::class; // 獲取容器中的對象實例 $cache = $app->cache; // 或者使用助手函數 $cache = app('cache'); ~~~ 5.0自動注入的方式有所區別,綁定操作不再使用`Request`對象而是直接注冊到容器`Container`類或者`Facade`類,并且支持模型事件和數據庫事件的依賴注入,依賴注入會首先檢查容器中是否注冊過該對象實例,如果有的話就會自動注入,例如: 我們可以給路由綁定模型對象實例 ~~~ Route::get('user/:id','index/Index/hello') ->bindModel('\app\index\model\User'); ~~~ 然后在操作方法中自動注入User模型 ~~~ <?php namespace app\index\controller; use app\index\model\User; use think\Controller; class Index extends Controller { public function hello(User $user) { return 'Hello,'.$user->name; } } ~~~
                  <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>

                              哎呀哎呀视频在线观看