theguy
theguy

Reputation: 49

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() output:

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

Upvotes: 2

Views: 3927

Answers (1)

Maryam Homayouni
Maryam Homayouni

Reputation: 943

Your code tries to look at the default namespace for imagick, so you have to write it like this, and it will find imagick class in a proper way:

$img = new \Imagick($full_name);

Upvotes: 0

Related Questions