brew install php
Check if Imagick is already installed
Before starting do check whether Imagick is already installed in the system.
php -m | grep imagick
Install Imagick dependency
The first thing to do is to install the necessary dependency for the setup. Do note that it will take some time to install the necessary dependency.
brew install pkg-config imagemagick
Install Imagick through PECL
Once that's done, run the command below to install Imagick using PECL command line.
pecl search imagick pecl install imagick brew services restart php
Update: 16/6/2021
If you are using macOS M1 and PHP version 7 or 8 and having some issues, do run the command below one at a time. Do specify your own PHP version below otherwise, it won't be able to symlink the file.
# install pcre2 brew install pcre2 # symlink the required file ln -ln -s /opt/homebrew/Cellar/pcre2/10.37/include/pcre2.h /opt/homebrew/Cellar/php/8.0.6_1/include/php/ext/pcre
git clone https://github.com/Imagick/imagick cd imagick phpize && ./configure make make test make install
brew services restart php # or if using laravel valet valet restart