[Solved] Fatal error: Uncaught Error: Class ‘Imagick‘ not found

Resolve fatal error: uncaught error: class’ imageick ‘not found

reason

PHP requires the imageick extension to be installed

environment

CentOS Linux release 7.9
PHP 7.3.26

Installation steps

Download the appropriate ImageMagick program and ImageMagick extension according to the environment

Installing imagemagic

wget http://www.imagemagick.org/download/ImageMagick.tar.gz

tar zxvf ImageMagick.tar.gz 
cd ImageMagick-7.1.0-8/
./configure --prefix=/usr/local/webservice/imagemagick
make && make install

Check whether the installation is successful

/usr/local/webservice/imagemagick/bin/convert -version

Version: ImageMagick 7.1.0-8 Q16-HDRI x86_64 2021-09-18 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(3.1) 
Delegates (built-in): fontconfig freetype jng jpeg lzma png x xml zlib
Compiler: gcc (4.8)

Installing the PHP extension: imagick

Download address

https://pecl.php.net/package/imagick
View the appropriate version download

 wget https://pecl.php.net/get/imagick-3.5.1.tgz
 tar zxvf imagick-3.5.1.tgz

cd imagick-3.5.1/
/usr/local/webservice/php73/bin/phpize
./configure --with-php-config=/usr/local/webservice/php73/bin/php-config --with-imagick=/usr/local/webservice/imagemagick
make && make install

Successful installation is displayed

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/webservice/php73/lib/php/extensions/no-debug-zts-20180731/
Installing header files:          /usr/local/webservice/php73/include/php/

Modify the configuration file and write extension=imagick.so

Add
extension=/usr/local/webservice/php73/lib/php/extensions/no-debug-zts-20180731/imagick.so at the end of vim /usr/local/webservice/php73/etc/php.ini

Restart php-fpm and test whether the installation is successful
systemctl restart php-fpm

php -m | grep imagick

Read More: