I was setting up a new Mac and ran into this problem again, where a default PHP installation with
brew is missing a few important extensions. In this case, I wanted to get the
imagick extension loaded.
This guide assumes you have Homebrew installed and you’ve installed PHP with
brew install php.
Install Image Magick dependency
imagemagick itself. This is needed to get the source files you’ll use later to compile the PHP extension with.
$ brew install pkg-config imagemagick
This will also install the needed
Compile Imagick PHP extension with pecl
Next up, use pecl to get the PHP extension compiled.
$ pecl install imagick [...] install ok: channel://pecl.php.net/imagick-3.4.4 Extension imagick enabled in php.ini
It will also auto-register itself in your php.ini and should now be available.
$ php -m | grep -i magic imagick
Note: if you run php-fpm, make sure you to restart your daemon to load the latest extension. Use
brew services restart php.