Reputation: 1988
I have some code which is resizing images, using either Imagick or GD, depending what's available on the server.
I'm testing for availability of each using the extension_loaded()
function.
if (extension_loaded('imagick')) {
$image = new Imagick();
...
}
I have one user reporting that they are receiving:
Fatal error: Class 'Imagick' not found
What circumstances would result in the Imagick extension being loaded but the class not available? How should I be testing to make my code more robust?
Upvotes: 3
Views: 873
Reputation: 1183
yum install ImageMagick yum install ImageMagick-devel pecl install imagick echo "extension=imagick.so" > /etc/php.d/imagick.ini service httpd restart [/etc/init.d/httpd restart] php -m | grep imagick
Upvotes: 0
Reputation: 11077
1: always do the checks in a case-insensitive manner (make the string lowercase before comparing it)
2: don't check for the library, check for features. Maybe it has a library version that's buggy or has other function names
3: in php.ini you may disable some functions explicitly by name so I think you should resort to point #2 and check with function_exists instead of extension_*
Also, take a look at /var/log/apache2/errors
or the equivalent on that client's server to check for any internal error generated by the ImageMagick extension (segmentation fault or other types of low-level errors should get reported in there...)
Upvotes: 2
Reputation: 223
You could check if the class exists also?
class_exists("Imagick")
Upvotes: 2