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

浙公网安备 33010602011771号