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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ### 路由分組 相信通過前面幾篇的學習,你已經掌握了基本的路由用法,本篇內容要講解的路由分組的引入是為了簡化路由規則的定義,以及提高路由的解析性能而設計的。 下面就來揭開分組的神秘面紗吧。 #### 分組定義 在實際的使用中,會涉及到大量的相同URL前綴的路由規則,例如下面的一組路由: ~~~ Route::get('blog/:year/:month','blog/archive',['ext'=>'html'],['year'=>'\d{4}','month'=>'\d{2}']); Route::get('blog/:cate','blog/index',['ext'=>'html'],['cate'=>'[a-zA-Z]+']); Route::get('blog/:id','blog/read',['ext'=>'html'],['id'=>'\d+']); Route::get('blog','blog/index',['ext'=>'html']); ~~~ 除了定義起來略顯麻煩之外,而且在匹配路由的時候也會整個遍歷,通過路由分組可以簡化為: ~~~ Route::group('blog', [ ':year/:month' => 'blog/archive', ':cate' => 'blog/index', ':id' => 'blog/read', '/' => 'blog/index', ],['ext'=>'html'],['year'=>'\d{4}','month'=>'\d{2}','cate'=>'[a-zA-Z]+','id'=>'\d+']); ~~~ 當然,也可以使用閉包方式定義: ~~~ Route::group('blog', function(){ Route::get(':year/:month','blog/archive'); Route::get(':cate','blog/index'); Route::get(':id','blog/read'); Route::get('/','blog/index'); },['ext'=>'html'],['year'=>'\d{4}','month'=>'\d{2}','cate'=>'[a-zA-Z]+','id'=>'\d+']); ~~~ 分組本身沒有請求類型的限制,也就是說分組對所有請求類型都是有效的,對請求類型有限制的是分組下面的路由規則本身。 【5.1須知】 5.1可以使用下面的方式更清晰注冊 ~~~ Route::group('blog', function(){ Route::get(':year/:month','blog/archive'); Route::get(':cate','blog/index'); Route::get(':id','blog/read'); Route::get('/','blog/index'); })->ext('html') ->pattern(['year'=>'\d{4}','month'=>'\d{2}','cate'=>'[a-zA-Z]+','id'=>'\d+']); ~~~ 路由分組在執行路由匹配的時候,首先會匹配URL地址是否為分組名開頭,如果符合才會進行分組下面的路由匹配。 當然,分組遠不止這么簡單,下面我們會陸續領略到分組的強大。 #### 路由地址前綴 可以給分組的路由地址定義一個統一的前綴 ~~~ Route::group('blog', [ ':year/:month' => ['archive', ['method'=>'get']], ':cate' => 'index', ':id' => 'read', ],['ext'=>'html','prefix'=>'index/blog/'],['year'=>'\d{4}','month'=>'\d{2}','cate'=>'[a-zA-Z]+','id'=>'\d+']); ~~~ 使用`prefix路由參數`統一配置路由地址的前綴,可以簡化分組的路由地址的定義。 #### 小結 路由分組的定義格式 > Route::group('分組名或分組參數','分組路由規則','公共路由參數','公共變量規則'); group方法的第一個參數為字符串表示分組名,如果是數組就表示該分組的公共路由參數。
                  <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>

                              哎呀哎呀视频在线观看