Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Swaz's avatar
Level 20

Using imagick with Valet?

How do you install and use imagick with Laravel Valet?

0 likes
19 replies
Swaz's avatar
Level 20

I already tried brew install imagick, it installed but do I need to tell php to use it somehow? It still didn't seem to be working.

Drfraker's avatar

You might have to enable it in the php.ini file or one that it is loading. You can determine if it is loaded in your php by going to the command line and typing php -i | grep Imagick if that command returns any information about Imagick then it is loaded. If not you are not loading php with Imagick included.

jsonkenyon's avatar

You are missing the php module in this case.

brew install pkg-config

Then run something like

pecl install imagick

Then you can check if you have it, by doing:

php -m | grep imagick

1 like
Swaz's avatar
Level 20

Took me a while to figure out what pecl was and to get that installed. Unfortunately once pecl is installed it's not as simple as running pecl install imagick, getting all kinds of other issues:

MagickWand-config... Doesn't exist, etc.

jsonkenyon's avatar

Post the error that you are getting if you can. running the pecl install should provide a make error if there is an error making it. Although the pecl should have been installed with the PHP that you are running. What version of PHP are you running? It is the brew installed PHP version?

You should be able to get most of that information from

pecl version

It will output something like:

# jason at argon in ~ [21:22:02]
→ pecl version
PEAR Version: 1.10.5
PHP Version: 7.2.12
Zend Engine Version: 3.2.0
Running on: Darwin argon 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64
Swaz's avatar
Level 20

@jkenyon I'm running the homebrew version of php.

PEAR Version: 1.10.5
PHP Version: 7.1.19
Zend Engine Version: 3.1.0
Running on: Darwin MyMacName 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64

When I run sudo pecl install imagick I get:

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading imagick-3.4.3.tgz ...
Starting to download imagick-3.4.3.tgz (245,410 bytes)
...................................................done: 245,410 bytes
19 source files, building
running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
Please provide the prefix of Imagemagick installation [autodetect] :
building in /private/tmp/pear/install/pear-build-rootPZogVi/imagick-3.4.3
running: /private/tmp/pear/install/imagick/configure --with-php-config=/usr/bin/php-config --with-imagick
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin18.2.0
checking host system type... x86_64-apple-darwin18.2.0
checking target system type... x86_64-apple-darwin18.2.0
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20160303
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable the imagick extension... yes, shared
checking for pkg-config... /usr/local/bin/pkg-config
checking ImageMagick MagickWand API configuration program... checking Testing /usr/local/bin/MagickWand-config... Doesn't exist
checking Testing /usr/bin/MagickWand-config... Doesn't exist
checking Testing /usr/sbin/bin/MagickWand-config... Doesn't exist
checking Testing /opt/bin/MagickWand-config... Doesn't exist
checking Testing /opt/local/bin/MagickWand-config... Doesn't exist
configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.
ERROR: `/private/tmp/pear/install/imagick/configure --with-php-config=/usr/bin/php-config --with-imagick' failed
jsonkenyon's avatar

@Swaz Hmmm, have you tried to run the pecl command with out sudo? Though that shouldn't really make a difference in this case. I ran it with out it. Try and reinstall the brew install imagemagick and then try the pecl install with out sudo.

Also try running pecl channel-update pecl.php.net before too

Swaz's avatar
Level 20

@jkenyon I wasn't having any luck, I just tried again and it worked! Though I seriously have no idea what I did differently this time haha. Thanks for all your help!

jsonkenyon's avatar

haha no worries! It happens, it use to be just a brew command, however, since they updated the core it removed the php extensions like that so now you have to use the pecl command.

denorm's avatar

Having just installed image magick successfully, I just wanted to say that you may need to run

valet restart

before the image magick module starts working correctly.

1 like
Zecka's avatar
Zecka
Best Answer
Level 1
  1. Install homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

if installation ask password many times run following command:

  • sudo chown -R $USER /usr/local

then Run following command:

  • brew install imagemagick
  • brew install pkg-config(also if it's already done)
  • pecl install imagick
  • valet restart
18 likes
Swaz's avatar
Level 20

I got this error running pecl install imagick

ERROR: failed to mkdir /usr/local/Cellar/php/7.3.6/pecl/20180731

I fixed it with:

pecl config-get ext_dir | pbcopy

mkdir -p {paste clipboard value}
6 likes
izshreyansh's avatar

This seems to do the trick on Valet.

brew install imagemagick
pecl install imagick
FoxRocks's avatar

@zecka You're a legend, I bet I've come back to your solution at least 4 times. Thanks!!

Please or to participate in this conversation.