PHP Fatal error: Class 'AMQPConnection' not found

I have already seen this question . This suggests that the AMQP PECL extension is not installed. However, I have successfully installed both RabbitMQ and built the PECL AMQP extension. Below is the output of phpinfo ().

phpinfo () output displaying AMQP extension configurations

You can clearly see AMQP 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 conclusion.

 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 could this happen? Any suggestions? Thanks.

+6
source share
2 answers

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 php.ini CLI file. Where exactly it depends on your platform.

+5
source

Can you add:

use PhpAmqpLib\Message\AMQPMessage;

under your:

use PhpAmqpLib\Connection\AMQPStreamConnection;

and it will work.

0
source

Source: https://habr.com/ru/post/901924/


All Articles