<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 功能強大 支持多語言、二開方便! 廣告
                ## 注解路由 ThinkPHP支持使用注解方式定義路由(也稱為注解路由),如果需要使用注解路由需要安裝額外的擴展: ``` composer require topthink/think-annotation ``` 然后只需要直接在控制器類的方法注釋中定義,例如: ~~~ <?php namespace app\controller; use think\annotation\Route; class Index { /** * @param string $name 數據名稱 * @return mixed * @Route("hello/:name") */ public function hello($name) { return 'hello,'.$name; } } ~~~ `@Route("hello/:name")` 就是注解路由的內容,請務必注意注釋的規范,不能在注解路由里面使用單引號,否則可能導致注解路由解析失敗,可以利用IDE生成規范的注釋。如果你使用`PHPStorm`的話,建議安裝`PHP Annotations`插件:https://plugins.jetbrains.com/plugin/7320-php-annotations ,可以支持注解的自動完成。 >[danger] 該方式定義的路由在調試模式下面實時生效,部署模式則在第一次訪問的時候生成注解緩存。 然后就使用下面的URL地址訪問: ~~~ http://tp5.com/hello/thinkphp ~~~ 頁面輸出 ~~~ hello,thinkphp ~~~ 默認注冊的路由規則是支持所有的請求,如果需要指定請求類型,可以在第二個參數中指定請求類型: ~~~ <?php namespace app\controller; use think\annotation\Route; class Index { /** * @param string $name 數據名稱 * @return mixed * @Route("hello/:name", method="GET") */ public function hello($name) { return 'hello,'.$name; } } ~~~ 如果有路由參數需要定義,可以直接在后面添加方法,例如: ~~~ <?php namespace app\controller; use think\annotation\Route; class Index { /** * @param string $name 數據名稱 * @Route("hello/:name", method="GET", https=1, ext="html") * @return mixed */ public function hello($name) { return 'hello,'.$name; } } ~~~ 支持在類的注釋里面定義資源路由,例如: ~~~ <?php namespace app\controller; use think\annotation\route\Resource; /** * @Resource("blog") */ class Blog { public function index() { } public function read($id) { } public function edit($id) { } } ~~~ 如果需要定義路由分組,可以使用 ~~~ <?php namespace app\controller; use think\annotation\route\Group; use think\annotation\route\Route; /** * @Group("blog") */ class Blog { /** * @param string $name 數據名稱 * @return mixed * @Route("hello/:name", method="GET") */ public function hello($name) { return 'hello,'.$name; } } ~~~ 當前控制器中的注解路由會自動加入`blog`分組下面,最終,會注冊一個`blog/hello/:name`的路由規則。你一樣可以對該路由分組設置公共的參數,例如: ~~~ <?php namespace app\controller; use think\annotation\route\Middleware; use think\annotation\route\Group; use think\annotation\route\Route; use think\middleware\SessionInit; /** * @Group("blog",ext="html") * @Middleware({SessionInit::class}) */ class Blog { /** * @param string $name 數據名稱 * @return mixed * @Route("hello/:name",method="GET") */ public function hello($name) { return 'hello,'.$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>

                              哎呀哎呀视频在线观看