先写个HTTP DEMO
<?php
class Server
{
public $server;
public function __construct(){
$this->server = new swoole_http_server('0.0.0.0',9501);
$this->server->on('start', [$this, 'onStart']);
$this->server->on('request' ,[$this,'onRequest']);
$this->server->start();
}
public function onStart($server){
echo "服务启动 http://0.0.0.0:9501",PHP_EOL;
}
public function onRequest($request,$response){
$response->end("hello");
}
public function onClose($server,$fd){
}
}
new Server();
试运行一下