找不到类 ZMQContext [英] Class ZMQContext not found

查看:53
本文介绍了找不到类 ZMQContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在装有 Ubuntu 14.04 的虚拟机内的 nginx 1.4.6 和 php 5.5 上运行 Web 服务器,并且需要安装 ZeroMQ 扩展.我已按照 ZMQ 上的说明进行操作(在类 UNIX 系统上构建 部分)em>),按照此处的指示添加了 php 语言绑定,针对我的 php 版本对其进行了编译并添加了线

I'm running web server on nginx 1.4.6 and php 5.5 inside a virtualized machine with Ubuntu 14.04 and need to install ZeroMQ extension. I have followed the instructions on ZMQ (the section To build on UNIX-like systems), added php language binding as instructed here, compiled it against my version of php and added the line

extension=zmq.so

/etc/php5/cli/php.ini 以及/etc/php5/fpm/php.ini,这是我唯一的.ini 文件.

to /etc/php5/cli/php.ini as well as to /etc/php5/fpm/php.ini, which are my only .ini files.

重新启动 nginxphp-fpm 后,php -i 显示如下:

After restarting nginx and php-fpm the php -i shows following:

$ php -i | grep -i zmq
zmq
ZMQ extension => enabled
ZMQ extension version => @PACKAGE_VERSION@
libzmq version => 4.0.4

所以 ZMQ 模块安装在 cli 中,但是当我使用 phpinfo(); 访问页面时,我没有看到 ZMQ 模块配置部分,当我访问该页面时,代码所在的位置$context = new \ZMQContext(); 被调用,我收到 error 消息:

So the ZMQ module is installed in cli, but when I visit a page with phpinfo(); I don't see the ZMQ module configuration section and when I access the page, where the code $context = new \ZMQContext(); is invoked, I get the error message:

未找到ZMQContext"类".

Class 'ZMQContext' not found".

ZMQ 模块显然已在 cli 中正确加载,但由于某种原因在 php-fpm 中无法识别.我已经仔细检查了 fpm php.ini 是否已加载并且带有扩展名的行在那里.

The ZMQ module is obviously loaded properly within the cli but for some reason it is not recognised in php-fpm. I have double checked that the fpm php.ini is loaded and that the line with extension is there.

我还有一个脚本 push-server.php,它在与 Ratchet 的循环中运行一个单独的 websocket 服务器,并侦听要推送给订阅者的传入消息:

I also have a script push-server.php that runs a separate websocket server in a loop with Ratchet and listens for incoming messages to be pushed to subscribers:

<?php
require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/app/libs/Pusher/Pusher.php';

$loop   = React\EventLoop\Factory::create();
$pusher = new App\Libs\Pusher\Pusher; // my own pusher implementation

$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:5555');
$pull->on('message', [$pusher, 'onMessageEntry']);
$pull->on('subscribe', [$pusher, 'onSubscribe']);

$webSock = new React\Socket\Server($loop);
$webSock->listen(8099, '0.0.0.0');
$webServer = new Ratchet\Server\IoServer(
    new Ratchet\Http\HttpServer(
        new Ratchet\WebSocket\WsServer(
            new Ratchet\Wamp\WampServer(
                $pusher
            )
        )
    ),
    $webSock
);

$loop->run();

执行 php push-server.php 后,它运行没有错误,因此 ZMQ 模块在 cli 中正确加载.

After executing php push-server.php it runs without errors so the ZMQ module is loaded properly in cli.

我已经尝试过此处,但没有运气.here 有一个类似的问题,但专注于 Windows 和wamp 服务器,到目前为止还没有答案.

I have already tried stuff suggested here, but no luck. There is a similar question here, but focused on windows and wamp server and so far without answer.

有谁知道为什么会这样?将不胜感激.

Does anyone have any idea why this is happening? It will be highly appreciated.

推荐答案

PHP升级到5.6后问题消失,所有模块加载无问题.

The problem disappeared after upgrading PHP to 5.6, all modules load without troubles.

这篇关于找不到类 ZMQContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆