首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
使用swoole时报swoole_server没有找到
在服务器上装了swoole用php -m 也看到了有,但是运行以下代码时却说swoole_server没有找到,这是什么原因啊?是我的文件位置没放对还是没有安装成功?才入手,还请大神帮忙 class server { private $serv; public function __construct() { $this->serv = new swoole_server("0.0.0.0", 9501); $this->serv->set(array('worker_num' => 8, 'daemonize' => false, 'max_request' => 10000, 'dispatch_mode' => 2, 'debug_mode' => 1)); $this->serv->on('Start', array($this, 'onStart')); $this->serv->on('Connect', array($this, 'onConnect')); $this->serv->on('Receive', array($this, 'onReceive')); $this->serv->on('Close', array($this, 'onClose')); $this->serv->start(); } public function onStart($serv) { echo "Start\n"; } public function onConnect($serv, $fd, $from_id) { $serv->send($fd, "Hello {$fd}!"); } public function onReceive(swoole_server $serv, $fd, $from_id, $data) { echo "Get Message From Client {$fd}:{$data}\n"; } public function onClose($serv, $fd, $from_id) { echo "Client {$fd} close connection\n"; } } $server = new server();
发布于10年前 · 7 次浏览 · 来自
提问
z
zhangzhijie
在服务器上装了swoole用php -m 也看到了有,但是运行以下代码时却说swoole_server没有找到,这是什么原因啊?是我的文件位置没放对还是没有安装成功?才入手,还请大神帮忙 class server { private $serv; public function __construct() { $this->serv = new swoole_server("0.0.0.0", 9501); $this->serv->set(array('worker_num' => 8, 'daemonize' => false, 'max_request' => 10000, 'dispatch_mode' => 2, 'debug_mode' => 1)); $this->serv->on('Start', array($this, 'onStart')); $this->serv->on('Connect', array($this, 'onConnect')); $this->serv->on('Receive', array($this, 'onReceive')); $this->serv->on('Close', array($this, 'onClose')); $this->serv->start(); } public function onStart($serv) { echo "Start\n"; } public function onConnect($serv, $fd, $from_id) { $serv->send($fd, "Hello {$fd}!"); } public function onReceive(swoole_server $serv, $fd, $from_id, $data) { echo "Get Message From Client {$fd}:{$data}\n"; } public function onClose($serv, $fd, $from_id) { echo "Client {$fd} close connection\n"; } } $server = new server();
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2016-07-31
寂
寂寞的钢蛋儿
有加命名空间吗?
赞
0
回复