I'm trying to instantiate Imagick
in a service class, however, I keep getting the following error message:
Class 'Imagick' not found in Gallery/Service/ImageUploadService.php
I've run convert -version
and I get the following response:
Version: ImageMagick 6.7.7-10 2018-07-10 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC Features: OpenMP
Here's my service class:
<?php
namespace Gallery\Service;
class ImageUploadService
{
private $Imagick;
private $pdflib;
public function __construct($pdflib)
{
$this->Imagick = new \Imagick();
$this->pdflib = $pdflib;
}
public function registerImage()
{
return 'success';
}
private function checkFileType()
{
}
private function sanitizeFileName()
{
}
}
I ran several of the commands I saw online but to keep it short, running the first command in the following fixed the issue for me:
sudo apt install libmagickwand-dev imagemagick php-dev
sudo pecl install imagick
sudo apt-get install php5.6-imagick
sudo service php5.6-fpm restart