How to install AMQP on macOS

Reading time  is 3 minute(s)

I recently wanted to install the AMQP extension for PHP version 7.4, but ran into some issues on macOS.

It should be as easy as running the following commands:

1brew install rabbitmq-c
2pecl install amqp

Unfortunately I ran into the following issues:

1Warning: mkdir(): File exists in System.php on line 294 PHP Warning: mkdir(): File exists in
2/usr/local/Cellar/php/7.4.10/share/php/pear/System.php on line 294 Warning: mkdir(): File exists in
3/usr/local/Cellar/php/7.3.3/share/php/pear/System.php on line 294 ERROR: failed to mkdir
4/usr/local/Cellar/php/7.4.10/pecl/20190812

The command fails because pecl can’t create the directories itself. This can be easily fixed by executing the following commands:

1pecl config-get ext_dir | pbcopy
2 
3mkdir -p $PASTECLIPBOARD

You should also manually export the PKG_CONFIG_PATH because Homebrew fails to do so.

1export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/Cellar/rabbitmq-c/0.10.0/lib/pkgconfig"

Now run the two commands again and it should work. I hope this helps anybody who also is running into this issue.