控制器 app/Controller/SiteController.php

<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\HttpServer\Annotation\AutoController;

/**
 * @AutoController()
 */
class SiteController
{
    public function index(RequestInterface $request, ResponseInterface $response)
    {
            $name = $request->input('name');
        return $response->raw('Hello,'.$name.PHP_EOL);
    }
}

测试访问

curl 118.195.173.53:9501/site/index?name=huyongjian

结果显示

Hello,huyongjian

相关文章:

  • 2021-10-26
  • 2022-12-23
  • 2021-10-01
  • 2021-10-02
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
相关资源
相似解决方案