hyperf 控制器

控制器 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
posted @ 2021-09-16 17:44  胡勇健  阅读(162)  评论(0)    收藏  举报