PHP 致命错误:类“AMQPConnection”未找到

发布于 2024-12-17 10:12:12 字数 632 浏览 3 评论 0原文

我已经看过这个问题。这表明未安装 AMQP PECL 扩展。但是,我已经成功安装了 RabbitMQ 以及构建的 PECL AMQP 扩展。以下是 phpinfo() 的输出。

phpinfo()输出显示AMQP扩展配置

您可以清楚地看到,AMQP已正确加载。但是,当我尝试建立连接时,它显示 PHP 致命错误:未找到“AMQPConnection”类。下面是代码。

$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

为什么会发生这种情况?有什么建议吗?谢谢。

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().

phpinfo() output displaying AMQP extension configurations

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();

And here is the output.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落画卷 2024-12-24 10:12:12

问题很可能是 CLI 安装使用与 web/Apache 模块不同的 php.ini 文件,并且您还需要将扩展​​名添加到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文