Why load a PHP extension when instantiating a class?

I have code that resizes images using Imagick or GD, depending on what is available on the server.

I test the availability of each of them using a function extension_loaded().

if (extension_loaded('imagick')) {
    $image = new Imagick();
    ...
}

I have one user who reports that they receive:

Fatal error: class "Imagick" not found

What circumstances will cause the Imagick extension to load, but the class is not available? How should I test to make my code more reliable?

+3
source share
4 answers

1: ( )

2: , . , ,

3: php.ini , , №2 _exists _ *

, /var/log/apache2/errors , , ImageMagick ( ...)

+2

, ?

class_exists ( "Imagick" )

+2

Case sensitivity?

'imagick' and Imagick.

0
source
    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

Link

0
source

Source: https://habr.com/ru/post/1718528/


All Articles