Class ZMQContext not found even though ZMQ is installed

后端 未结 4 1487
小蘑菇
小蘑菇 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条回答
  •  猫巷女王i
    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

    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.

提交回复
热议问题