<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 配置方式 > 配置文件:config/routes.php ~~~ use Hyperf\\HttpServer\\Router\\Router; // 下面三種方式的任意一種都可以達到同樣的效果 Router::get('/hello-hyperf', 'App\\Controller\\IndexController::hello'); Router::post('/hello-hyperf', 'App\\Controller\\IndexController@hello'); Router::get('/hello-hyperf', [App\\Controller\\IndexController::class, 'hello']); ~~~ ## 注解方式 > phpstorm中需要安裝 PHP Annotations 插件,便于語法提示 ### @AutoController 注解 > `@AutoController`會為所有`public`方法并提供`GET`和`POST`兩種請求 ~~~ declare(strict_types=1); namespace App\Controller; use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Annotation\AutoController; /** * @AutoController() */ class UserController { // Hyperf 會自動為此方法生成一個 /user/index 的路由,允許通過 GET 或 POST 方式請求 public function index(RequestInterface $request) { // 從請求中獲得 id 參數 $id = $request->input('id', 1); return (string)$id; } } ~~~ ### @Controller 注解 > `@Controller`為更細致的路由定義需求,需同時配合`@RequestMapping` 或 (`@GetMapping`、`@PostMapping`) ~~~ declare(strict_types=1); namespace App\Controller; use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\RequestMapping; /** * @Controller() */ class UserController { // Hyperf 會自動為此方法生成一個 /user/index 的路由,允許通過 GET 或 POST 方式請求 /** * @RequestMapping() */ public function index() { return 'test'; } /** * @RequestMapping(path="user", methods="get,post") */ public function user(RequestInterface $request) { // 從請求中獲得 id 參數 $id = $request->input('id', 1); return (string)$id; } } ~~~ ## 路由參數定制 > 配置文件:config/routes.php ~~~ Router::get('/user/{id}', 'App\\Controller\\UserController::info'); ~~~ > 修改/app/Controller/UserController.php ~~~ public function info(int $id) { $user = User::find($id); return $user->toArray(); } ~~~
                  <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>

                              哎呀哎呀视频在线观看