<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## **創建中間件** 在 application/http/middleware 目錄下面一個User中間件。 ~~~ <?php namespace app\http\middleware; class User{ public function handle($request, \Closure $next){ return $next($request); } } ~~~ >[success] 在一些項目開發過程中. 也可能會使用到前置和后置的需求。 > 那么就可以將前置和后置中間件放在同一個文件了 ## **前置/后置中間件** ~~~ <?php namespace app\http\middleware; class User{ public function handle($request, \Closure $next){ //前置 添加中間件執行代碼 Start echo '我是前置'; //前置 添加中間件執行代碼 End $response = $next($request); //后置 添加中間件執行代碼 Start echo '我是后置'; print_r( $response->getData() ); //獲取控制器index()方法返回的數據 //后置 添加中間件執行代碼 End return $response; } } ~~~ >[info] 調用也是比較簡單的,這里只介紹用控制器的調用方法。 ## **控制器調用** ~~~ <?php namespace app\index\controller; class User{ //指定方法調用中間件 protected $middleware = [ '\app\http\middleware\User' => ['only' => ['index'] ], ]; public function index(){ echo 'index'; return ['code'=>1,'message'=>"處理成功"]; //返回數據到前端 中間件也可以獲取 } } ~~~ ## **運行效果** ~~~ 我是前置 index 我是后置 Array ( [code] => 1 [message] => 處理成功 ) ['code'=>1,'msg'=>"處理成功"] ~~~
                  <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>

                              哎呀哎呀视频在线观看