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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 2019 年 1 月 16 日 發布 ThinkPHP`5.2`的路由部分,也和其它組件一樣,做了精簡和優化,主要包括如下方面: >[danger] `5.2`版本目前尚未正式發布,在正式發布之前可能仍然會存在變化。 ## 取消路由定義的返回數組形式 >[danger] 因為不利于路由緩存生成,路由定義文件取消了返回數組的方式定義路由,必須采用路由方法注冊路由。 例如: ``` return [ 'hello/:name' => 'index/hello', ]; ``` 必須改成: ``` Route::get('hello/:name', 'index/hello'); ``` ## 多應用的路由定義文件位置 單應用模式下,路由定義文件和之前一樣就在`route`目錄下面,如果你的項目是采用了多應用的話,每個應用的路由定義和匹配都是獨立的,也沒有模塊的概念,路由定義文件的位置應該是在`route/應用子目錄`下面,例如: ``` route/index/route.php // index應用的路由定義文件 route/index/web.php // index應用的第二個路由定義文件 route/admin/route.php // admin應用的路由定義文件 ``` 默認的URL規則變成了 ``` http://域名/入口文件(或者應用名)/控制器名/操作名 ``` >[danger] 應用的路由規則其實是定義的入口文件(或者應用名)后面的URL部分,而不包含應用。 ## 自動多應用 最新的5.2版本可以支持在同一個入口文件中訪問多個不同的應用(之前必須每個應用添加一個對應的入口文件)。 例如在`index.php`入口文件中使用: ``` (new App())->autoMulti()->run()->send(); ``` 就可以不必創建入口文件自動通過URL訪問多個應用 ``` http://serverName/index.php/admin ``` 如果你的默認應用不是`index`(默認為入口文件名),那么可以通過`name`方法指定默認應用。 ``` (new App())->autoMulti() ->name('admin') ->run() ->send(); ``` 支持應用名的別名映射,例如: ``` (new App())->autoMulti([ 'think' => 'admin', // 把admin應用映射為think ])->run()->send(); ``` 如果需要對某個應用進行自定義,可以使用 ``` (new App())->autoMulti([ 'admin' => function($app) { $app->debug(true)->useClassSuffix(); } ])->run()->send(); ``` ## 取消別名路由 因為使用場景有限和性能開銷問題,取消原來的別名路由功能,建議使用資源路由或者單獨的路由替代。 ## 取消快捷路由 因為使用場景有限和不太符合規范,取消了原來的控制器快捷路由功能。 ## 取消空控制器和空操作 原來的空控制器和空操作功能已經取消,請使用`MISS`路由功能替代,而且可以支持給不同的路由分組設置`MISS`路由。同時廢棄`empty_controller`配置。 ## 取消控制器自動搜索 由于性能原因,取消了路由的多級控制器自動搜索功能,請在路由規則定義中明確指定要路由的多級控制器。 ## 路由功能獨立設計 路由功能不再固定執行,而且設計成為`AppInit`事件的響應監聽,并且可以在項目的事件定義里面配置,系統默認的定義配置如下: ``` return [ 'bind' => [ ], 'listen' => [ 'AppInit' => [ 'think\listener\LoadLangPack', 'think\listener\RouteCheck', ], 'AppBegin' => [ 'think\listener\CheckRequestCache', ], 'ActionBegin' => [], 'AppEnd' => [], 'LogLevel' => [], 'LogWrite' => [], 'ResponseSend' => [], 'ResponseEnd' => [], ], 'subscribe' => [ ], ]; ``` 在`AppInit`事件中會執行`think\listener\RouteCheck`類,如果你的應用完全不需要使用任何的路由功能,可以在配置文件中取消定義即可,系統會執行默認的URL調度(也即是控制器/操作)。 ## 取消注冊方法的`option`和`pattern`參數 取消路由注冊方法(包括`rule`/`get`/`post`/`put`/`delete`/`patch`/`miss`/`group`等方法)的`option`和`pattern`參數,全部改成方法調用形式,例如原來的: ``` Route::get('hello/:name', 'index/hello', [ 'ext' => 'html'], [ 'name' => '\w+']); ``` 需要改成 ``` Route::get('hello/:name', 'index/hello') ->ext('html') ->pattern([ 'name' => '\w+']); ``` ## 路由分組定義不再支持數組 因為不利于分組的嵌套功能,路由分組定義不再支持數組,只能使用閉包方式定義,例如: ~~~ Route::group('blog', [ ':id' => 'Blog/read', ':name' => 'Blog/read', ])->ext('html')->pattern(['id' => '\d+']); ~~~ 必須改成 ~~~ Route::group('blog', function() { Route::get(':id', 'Blog/read'); Route::get(':name', 'Blog/read'); })->ext('html')->pattern(['id' => '\d+']); ~~~ 如果你需要注冊一個虛擬的路由分組,可以直接在第一個參數使用閉包 ~~~ Route::group(function() { Route::get('blog/:id', 'Blog/read'); Route::get('user/:name', 'User/read'); })->ext('html')->pattern(['id' => '\d+']); ~~~ ## 取消了`url_controller_layer`配置 改為在入口文件中使用`controllerLayer`方法設置。 ``` (new App())->controllerLayer('Action') ->run() ->send(); ``` ## 取消`class_suffix`配置 改為在入口文件中使用`useClassSuffix`方法設置。 ``` (new App())->useClassSuffix(true) ->run() ->send(); ``` 同時取消`controller_suffix`和`class_suffix`配置參數。 ## 取消`mergeExtraVars`方法和對應參數 改為在路由規則中明確指定變量規則。 ## `header`方法參數類型調整 由于強類型約束的原因,`header`方法改為僅支持數組參數傳入。 ## 使用強類型參數 由于全面啟用強類型參數,并且使用嚴格模式,所以一定要注意參數的類型。
                  <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>

                              哎呀哎呀视频在线观看