After setting up Laravel Valet and MySQL with Homebrew a while ago, local development has been pretty smooth sailing. Today though, I ran in to some trouble getting the Imagick extension up and running. After some searching online, this discussion thread got me going in the right direction.
I had Homebrew and
pkg-config installed already, so the first thing I did was install ImageMagick with Homebrew by running
brew install imagick. Next, I installed the Imagick extension with PECL by running
pecl install imagick. It’s worth keeping an eye on the output related to this installation. At the very end of the output, I got this error:
ERROR: failed to mkdir /usr/local/Cellarfirstname.lastname@example.org/7.2.19_1/pecl/20170718
Someone else in the discussion thread ran in to a similar problem, so I roughly followed their directions. I ran
pecl config-get ext_dir to get the extensions directory that the PECL config expects, then I copied that output and ran
mkdir -p . I then ran
pecl install imagick again, and this time there were no errors. Note that the output from this successful installation ended in
Extension imagick enabled in php.ini.
To wrap it all up, I ran
valet restart and then ran
php -i | grep Imagick to check that Imagick Imagick in the PHP configuration. It returned a few lines in relation to classes and the ImageMagick version indicating that everything is set up as necessary.
Note that this only applies to the PHP version that is currently in use by Valet. I use a few different versions depending on the project, so I’ve repeated the
pecl install imagick step for each of those versions as well.