简体   繁体   中英

Laravel 5.4 Class Imagick not found, while it is installed

PHP has all imagick libs, but in Laravel 5.4 it said class not found.

Code:

$img = new Imagick($full_name);

This if(extension_loaded('imagick')) returns true. So it's installed.

phpinfo() output: phpinfo()输出:

Any help why Laravel treat PHP class as it's own?

ERROR for $img = new \\Imagick($full_name): FatalErrorException Class 'Imagick' not found

ERROR for $img = new Imagick($full_name) : FatalErrorException Class 'App\\Http\\Controllers\\Imagick' not found

您的代码尝试查看imagick的默认名称空间,因此您必须像这样编写它,它将以适当的方式找到imagick类:

$img = new \Imagick($full_name);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM