Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

rabbitmq - PHP Fatal error: Class 'AMQPConnection' not found

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...