Class ZMQContext not found even though ZMQ is installed

后端 未结 4 1474
小蘑菇
小蘑菇 2020-12-17 18:50

First of all, yes I am aware that there is a very similar question out there, but the answer given there doesn\'t apply to my situation, and there\'s no indication that it f

相关标签:
4条回答
  • 2020-12-17 19:24

    I have not used ZMQ but this seems like a configure problem.

    First, run PHP in cli and in apache can use different php.ini

    Eg in ubuntu 12.04:

    /etc/php5/apache2/php.ini is used for apache
    /etc/php5/cli/php.ini is used for cli
    

    To check if ZMQ is currently loaded in apache, create a php file contains phpinfo(); and check it's output through web browser, there should be some info about ZMQ, use ctrl-f to search for it.

    In cli, php -m will show loaded/compiled module or extension.

    Second, ZMQ version

    I can't thought other reason than you used a ZMQ version which hasn't ZMQContext ? You could check ZMQ document and the version you used.

    (Deleted, should not be this problem according error message), namespace

    if ZMQ is currectly loaded, and your code still doesn't work, the another possible reason is use of namespace. If your post.php is like

    <?php
    namespace Some\NameSpace;
    $context = new ZMQContext();
    

    Then it means ZMQContext in namespace Some\NameSpace, the full quanlified classname is Some\NameSpace\ZMQContext, which doesn't exists. So you may need use \ZMQContext for class out of current namespace.

    0 讨论(0)
  • 2020-12-17 19:24

    If you use Wampserver, copy libzmq.dll file into C:\wamp64\bin\apache\apache2.4.17\bin and restart wamp.

    0 讨论(0)
  • 2020-12-17 19:30

    If the extension is enabled you still need to use this:

    use \ZMQContext;
    use \ZMQ;
    

    (or alternatively directly access them using a leading "\")

    0 讨论(0)
  • 2020-12-17 19:30

    You need to restart Apache before using new extensions. mod_php doesn't add modules during runtime

    0 讨论(0)
提交回复
热议问题