在 event 里面 ,onmessage 里面如何 嵌入 thinkphp

刘强
4947 5 0
5个回答

walkor

thinkphp 是web框架,它是专门为PHP CGI容器设计的,与http协议及相关函数接口耦合在一起,无法直接在workerman中运行。需要一些改造才能在workerman中运行。如果要用thinkphp,建议用apache/nginx/php-fpm传统容器去运行,毕竟thinkphp是为它们而设计

  • 暂无评论
刘强

如果evnt 执行的操作,过多有什么方式,可以将其拆分成不同,控制器运行

  • 暂无评论
walkor

路由方法很多,比如下面这种

pubic static function onMessage($client_id, $message)
{
    // $message 类似 {"class":"User", "method":"getUserInfoByName", "args":}
    $data = json_decode($message, true);
    $class = $data;
    $method= $data;
    $args = $data;
    call_user_function_array(array($class, $method), $args);
}
  • 879042886 2018-08-08

    已经完善 请查看http://wenda.workerman.net/?/article/64

刘强
pubic static function onMessage($client_id, $message)
{
    // $message 类似 {"class":"User", "method":"getUserInfoByName", "args":}
    $data = json_decode($message, true);
    $class = $data;
    $method= $data;
    $args = $data;
    call_user_function_array(array($class, $method), $args);
}

如果将 class 为 user 放在 另外一个 文件里面 则 event.php 必须要采用 "use \" 引进文件???

  • 暂无评论
walkor

require也行,利用php autoload也行

  • 暂无评论
年代过于久远,无法发表回答
🔝