Install ImageMagick When Using Laravel Valet

If you want to use ImageMagick with Laravel Valet, you have to install it using homebrew:

brew install imagemagick
pecl install imagick

pecl install imagick may lead to this error message:

$ pecl install imagick
[...]
checking for pkg-config... no
pkg-config not found
configure: error: Please reinstall the pkg-config distribution
ERROR: `/private/tmp/pear/temp/imagick/configure --with-php-config=/usr/local/opt/php/bin/php-config --with-imagick' failed

To fix this problem, run:

brew instal pkg-config

Now, pecl install imagick should work:

pecl install imagick