PHP致命错误:找不到类"AMQPConnection"
我已经看过这个问题.这表明未安装AMQP PECL扩展.但是,我已经成功安装了RabbitMQ和内置的PECL AMQP扩展.以下是phpinfo()的输出.
I've already seen this question. It suggests that AMQP PECL extension is not installed. However, I have successfully installed both RabbitMQ as well as built PECL AMQP extension. The following is the output of the phpinfo().
您可以清楚地看到,AMQP已正确加载.但是,当我尝试建立连接时,它显示 PHP致命错误:找不到类'AMQPConnection'.下面是代码.
You can clearly see, AMQP is loaded correctly. However, when I try to establish a connection, it says PHP Fatal error: Class 'AMQPConnection' not found. Below is the code.
$connection = new AMQPConnection();
这是输出.
user@ubuntu:~$ php repos/default/test.php
PHP Fatal error: Class 'AMQPConnection' not found in /home/user/repos/default/test.php on line 5
为什么会发生这种情况?有什么建议?谢谢.
Why this might happen? Any suggestions? Thank you.
问题很可能是CLI安装所使用的php.ini文件不同于Web/Apache模块,并且您需要将扩展名添加到CLI php .ini文件.确切的位置取决于您的平台.
The problem is most likely that the CLI installation uses a different php.ini file than the web/Apache module and you need to add the extension to the CLI php.ini file as well. Where exactly that is depends on your platform.