如何解决 - 致命错误:未捕获错误:找不到类'ZMQContext'?

时间:2018-02-25 02:12:20

标签: php zeromq failed-installation

我已经在WAMP中成功安装了ZeroMQ,请参见下面的截图。

但是我收到了错误:

  

致命错误:未捕获错误:在C:\ wamp64 \ www \ 0MQ \ zguide \ examples \ PHP \ hwclient.php中找不到类'ZMQContext':9堆栈跟踪:#0 {main}在C:\ wamp64中抛出第9行\ www \ 0MQ \ zguide \ examples \ PHP \ hwclient.php

当我在浏览器中运行测试脚本时:

enter image description here

TEST SCRIPT:

<?php
/*
 *  Hello World client
 *  Connects REQ socket to tcp://localhost:5555
 *  Sends "Hello" to server, expects "World" back
 * @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
 */

 $context = new ZMQContext();

 //  Socket to talk to server
 echo "Connecting to hello world server...\n";
 $requester = new ZMQSocket($context, ZMQ::SOCKET_REQ);
 $requester->connect("tcp://localhost:5555");

 for ($request_nbr = 0; $request_nbr != 10; $request_nbr++) {
    printf ("Sending request %d...\n", $request_nbr);
    $requester->send("Hello");

    $reply = $requester->recv();
     printf ("Received reply %d: [%s]\n", $request_nbr, $reply);
}

我该如何处理?

1 个答案:

答案 0 :(得分:0)

我添加了这个配置行:

[ZMQ]
extension=php_zmq.dll

php.ini 位于:

c:\wamp64\bin\php\php7.1.9\php.ini 

而不是:

c:\wamp64\bin\apache\apache2.4.27\bin\php.ini

这解决了这个问题。