Install ZeroMQ on Mac with PHP PECL extension

Getting ZeroMQ working on a Mac looks like a pain if you try to compile, but there’s a much easier way to get it up and running, with just a few brew and PECL commands.

I’ve been wary of Homebrew for a while, as there were lots of issues with Macports in the past, but I’ve found it’s a lot easier than trying to compile various things yourself in OS X (I tried to compile 0MQ, which took a while and ended up broken anyway)


Install Homebrew and ZeroMQ

Grab a copy of Homebrew then run the following command

brew install zeromq

Then once this is installed, install the PECL extension for PHP

Enable ZeroMQ support for PHP

sudo pear channel-discover
sudo pecl install


If you have more than one PHP binary on your computer (such as if you are using Zend Server on OS X, which means you will have the default PHP binary and the Zend PHP binary) then even if 0MQ looks like it is enabled using phpinfo() you may still get the following error from Composer:

– Installation request for react/zmq dev-master -> satisfiable by react/zmq[dev-master].
– react/zmq dev-master requires ext-zmq * -> the requested PHP extension zmq is missing from your system.

This is because Composer uses the PHP-CLI binary to both check and install things, meaning that unless it’s enabled for the binary it’s looking at, it won’t install, even if your web server has it enabled.

You just need to add (even temporarily) the correct PHP binary to the shell path:

export PATH=/usr/local/zend/bin:$PATH

(change depending on where your other binary is)

Then run composer.phar install again and it should work.


  • Things to note the channel for “” is moved to another server already “”.

    Then, you can continue using this command: sudo pecl install pecl/zmq

    There’s will be an error showed up. Saying about the stable version. Due to beta release of zmq-1.1.3 on You can only continue to install using specific version instead: sudo pecl install/zmq-1.1.3

    It’ll install your zmq. Don’t forget to install autoconf, make, etc. That dependencies needs to be installed first.

    Hopefully your zmq will installed flawlessly.

    *But, I do recommend just do this tutorial instead:
    *Compiling the POSIX Tarball, instead of manually installing from It’s much easier though 😀

  • /private/tmp/pear/temp/zmq/zmq.c:210:50: warning: format specifies type ‘long’ but the argument has type ‘zend_long’ (aka ‘long long’) [-Wformat]
    plist_key = strpprintf(0, “zmq_context=[%ld]”, io_threads);
    ~~~ ^~~~~~~~~~
    /private/tmp/pear/temp/zmq/zmq.c:238:20: error: expression is not assignable
    GC_REFCOUNT(&le) = 1;
    ~~~~~~~~~~~~~~~~ ^
    /private/tmp/pear/temp/zmq/zmq.c:526:53: warning: format specifies type ‘long’ but the argument has type ‘zend_long’ (aka ‘long long’) [-Wformat]
    return strpprintf(0, “zmq_socket:[%ld]-[%s]-[%d]”, type, persistent_id->val, use_shared_ctx);
    ~~~ ^~~~
    /private/tmp/pear/temp/zmq/zmq.c:538:19: error: expression is not assignable
    GC_REFCOUNT(&le) = 1;
    ~~~~~~~~~~~~~~~~ ^
    2 warnings and 2 errors generated.
    make: *** [zmq.lo] Error 1
    ERROR: `make’ failed

    What am I doing wrong?