When working with multiple version of PHP installed via Homebrew, there’s a chance you’ll encounter error messages like this:
PHP Warning: Module 'imagick' already loaded in Unknown on line 0 PHP Warning: Version warning: Imagick was compiled against Image Magick version 1809 but version 1808 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0
Granted, the version number may be different but the rest of the message will be the same. When I’ve experienced this, it’s when I’ve a set up like this:
- I have multiple versions of PHP installed (anything from the earliest build in 7 up to the latest version in 8),
- I swap among versions in my
~/.zshrc
file depending on the project, - When I attempt to run code that’s on an older version of PHP after installing and using the newer or latest version of PHP, I see the above error.
To fix this, there are two things you can do:
- Locate the version of the
php.ini
file for the version of PHP you’re currently using, - Update the
php.ini
file for the version to disable the version check on Imagick.