php - Class 'Imagick' not found in ZF2

279

I'm trying to instantiateImagick in a service class, however, I keep getting the following error message:

Class 'Imagick' not found in Gallery/Service/ImageUploadService.php

I've runconvert -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()
    {

    }
}
900

Answer

Solution:

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 

People are also looking for solutions to the problem: How to find rowCount in pdo prepare in php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.