1
votes

I have RabbitMQ running on one of our servers and am trying to connect to it via PHP. I am developing on a Windows7 machine and my first line of code reads: $cnn = new AMQPConnection();

It gives me the error: Fatal error: Class 'AMQPConnection' not found in

I know that it is something that I need to install but what is it ? I am new to PHP so a little help would be nice.

Ps: I can connect to the RMQ server via the RabbitMQ admin web interface.

Thank you Jack

5
The answer you accepted is no longer correct. RabbitMQ and also amqp are now available for Windows too.Wilt

5 Answers

1
votes

I am developing on a Windows7 machine

You may be out of luck using that specific code. That class is from the PECL aqmp extension. Inside the installation instructions, it states:

Note to Windows users: This extension does not currently support Windows since the librabbitmq library does not yet support Windows.

You will want to use another library to speak to your message queue instead.

2
votes

Installation guide for php_amqp 1.4.0 (Stable version):

  1. Download proper package for your php version from https://pecl.php.net/package/amqp/1.4.0/windows
  2. Unpack php_amqp.dll to X:/php/ext/ directory
  3. Unpack rabbitmq.1.dll to X:/Windows/system (not system32) directory
  4. Modify php.ini file and add "extension=php_amqp.dll" line at the end of extensions list
  5. Verify module installation by executing command "X:/php/php.exe -m" in command line
  6. Restart webserver
1
votes

The rabbitmq-c library supports windows now, and the php_amqp pecl extension builds on windows as well. The documentation just hasn't been updated, nor are there any official binary builds in the wild. However, I managed to get them to build and have some 32 bit dll's available for download here:

http://www.nathanjohnson.info/?p=77

0
votes

@ AMQP installation php.net:

Note to Windows users: This extension does not currently support Windows since the librabbitmq library does not yet support Windows.

But here at RabbitMQ website is a windows installer...

Apparently this php.net page is outdated


To install do like this:

  1. Download the correct package for your php from this official PECL amqp 1.4.0 page
  2. unzip
  3. add amqp.dll to your php ext folder
  4. add rabbitmq.1.dll to your windows system 32 folder.

This according to the post on the blog I found here i think it is from the same @NathanJohnson who posted also here.

0
votes

How I got it working:

My System Config: Win 7 Pro, (x64) XAMPP running PHP 5.6(x86)

Follow instruction from here to install RabbitMQ:

https://www.rabbitmq.com/install-windows.html

Now download compatible extension from here

https://pecl.php.net/package/amqp/1.4.0/windows

in my case it is "5.6 Thread Safe (TS) x86"

Now from zip file (php_amqp-1.4.0-5.6-ts-vc11-x86.zip) downloaded copy dll "php_amqp.dll" to your php extension folder in my case it is "xampp/php/ext" and copy dll "rabbitmq.1.dll" to "Windows\system" directory.

now register your php_amqp dll in php.ini file as "extension=php_amqp.dll"

now restart apache.

Done. Now you should not get AMQPConnection not found exception.