PHP7.2 Image Magick

Written by James McDonald

June 18, 2018

On a brew installed php7.2 on my MacOS 10.13.5 I get an error when running /usr/local/php5/bin/php from the command line:

Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/' (tried: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/ (dlopen(/usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/, 9): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.5.dylib
Referenced from: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/
Reason: image not found), /usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718//usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/ (dlopen(/usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718//usr/local/php5/lib/php/extensions/no-debug-non-zts-20170718/, 9): image not found)) in Unknown on line 0

Apparently you install php72-imagick differently these days as per this stack overflow answer:

I found I had to run the commands using sudo because my /usr/local couldn’t be written by my user and the pecl channel needs updating:

sudo pecl channel-update
sudo brew update # check for new formulas
sudo brew upgrade # pull down the latest of everything for your brew environment
sudo brew install php # not needed if already installed
sudo brew install imagemagick # not needed if already installed
sudo pecl install imagick
# after the above you can then run php without all the missing imagick error messages
/usr/local/php5/bin/php -v
PHP 7.2.2 (cli) (built: Feb  1 2018 13:23:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.2, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans


Submit a Comment

Your email address will not be published.

You May Also Like…


Zebra Printer Language The above website has a page where you can enter ZPL and it...

PHP Iterators

Just came across a Youtube talk "Iterators in PHP" by Jake Smith published in 2014 that steps through the many...

PHP array_map Multiple Arrays

array_map can take multiple arrays. I like how it starts mapping through them starting at the first element of each...