MrMooky's avatar

Shell error with imagick

I just wanted to install ImageMagick with PHP 8 on my local machine. But I spend the last couple of hours trying to fix errors with brew and valet and boy oh boy – I could just set everything on fire right now!

Basically, I re-installed and re-everythinged a few times now but still end up with the following error when I run valet install.

Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20200930/imagick.so (dlopen(/usr/local/lib/php/pecl/20200930/imagick.so, 9): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.7.dylib
  Referenced from: /usr/local/lib/php/pecl/20200930/imagick.so
  Reason: image not found), /usr/local/lib/php/pecl/20200930/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20200930/imagick.so.so, 9): image not found)) in Unknown on line 0
Could not open input file: 
Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20200930/imagick.so (dlopen(/usr/local/lib/php/pecl/20200930/imagick.so, 9): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.7.dylib
  Referenced from: /usr/local/lib/php/pecl/20200930/imagick.so
  Reason: image not found), /usr/local/lib/php/pecl/20200930/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20200930/imagick.so.so, 9): image not found)) in Unknown on line 0

Parse error: syntax error, unexpected identifier "imagick", expecting ")" in Command line code on line 2/cli/valet.php

I don't know why it says "imagick.so.so" and I don't know why valet.php complains about an expecting ) there. I haven't even touched that file.

Anybody have some idea what could be wrong and how to fix this?

Oh and the folder 20200930 did not contain the image, but I copied the one from my PHP 7.4 folder, so it is not empty.

0 likes
7 replies
MrMooky's avatar

Uhm, this is not about GD, but ImageMagick. GD is running just fine. IM is actually installed, but there is something else going wrong. And I don't get why this valet.php file is complaining.

rxtdev's avatar

@mrmooky i am having the same issue with laravel valet running an isolated php version of 8.0 for my project. Global php version is 8.2, when I installed imagick, it got all setup to 8.2. Tried to change the extension_dir pointing to the same path that 8.2 uses where imagick.so is, however, it gave me the same error that you got. I've tried to follow the steps from the link you gave but it ended setting up the global PHP version again which 8.2.

Did you had some different tweaks to do to make it work with an isolated php version?

MrMooky's avatar

@rxtdev Not sure about different tweaks (it's been a while). I'm currently using PHP Monitor (https://phpmon.app) that shows you if imagick.so is installed correctly with the PHP version you are using. I remember installing imagick.so a couple of times in a few different ways until it worked.

Please or to participate in this conversation.