I’m currently preparing my brand new Macbook Air for WordPress plugin development. I have installed PHP 8.1 using homebrew, a well-known package manager for most software developers using Mac. After installing WordPress, I notice WordPress complained about missing imagick library. I tried to install but encountered an error.
As per my google search, most article suggested the PHP to be installed using shivammathur package (here). Hence, I use that package to allow me to install multiple PHP version on my Mac. This is the way I use to install imagick (as per this article).
$ brew install pkg-config imagemagick $ pecl install imagick
To my surprise, it didn’t work well. I received an error stating the file already exists.
I open the directory /opt/homebrew/Cellar/php@7./7.4.32 and I rename the file with name pecl to pecl.bak (for backup purpose. just in-case)
$ cd /opt/homebrew/Cellar/[email protected]/7.4.32 $ mv pecl pecl.bak
I re-run the pecl install imagick and everything seems well. Also, I do noted the installation directory is different from what have been defined in php.ini.
Hence, it is an expected surprise when I try to run $ php -v, I received another error.
Hence, I locate my php.ini file and look for extension_dir line and change it according to the location where the imagick has been installed.
Now I’m able to run $ php -v without any errors and imagick are successfully installed. However, do note, this will only work for PHP 7.4. Due to unknown reason, you need to define the full path to imagick extension in php.ini file for PHP 8.1.
If you found a reason and/or any other solution with the need of defining full path, kindly share with me at the comment section below ?.