cakephppluginsphp-imagine

Plugin cakephp-imagine-plugin


I working with cakephp 3.0.x-dev and I would like to use the plugin cakephp-imagine-plugin ( https://github.com/burzum/cakephp-imagine-plugin/tree/3.0 ).

When I use this plugin I get the following error in my cakephp view

Error: Imagick not installed

My controller looks like

namespace App\Controller;
use App\Controller\AppController;
use Imagine\Imagick\Imagine; 

class AccueilController extends AppController {

     public function index() {

         $directory = 'webroot'.DS.'img'.DS.'Carousel'.DS;

         //get all image 
         $images = glob($directory . "*.{jpg,JPG,jpeg,JPEG,png,PNG}",GLOB_BRACE);

         // resize image if necessary.. format(900x500)
         $height = 500;
         $width = 900;
         foreach($images as $image)         
         {
             $image = new Imagine();
             //.. do some processing operation
         }
    // send data to the view
    $this->set('images', $images);
   }
}

I have installed the plugin view thanks to php composer.phar. The composer.json file looks like :

 {
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "http://cakephp.org",
"type": "project",
"license": "MIT",

"require": {
    "php": ">=5.4.16",
    "cakephp/cakephp": "3.0.*-dev",
    "composer/installers": "*",
    "mobiledetect/mobiledetectlib": "2.*",
    "cakephp/debug_kit": "3.0.*-dev",
    "imagine/imagine": "*",
    "composer/installers": "*"

},
"require-dev": {
    "d11wtq/boris": "1.0.*"
},
"extra": {
    "installer-name" : "Imagine"
},
"suggest": {
    "phpunit/phpunit": "Allows automated tests to be run without system-wide install.",
    "cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP."
},
"autoload": {
    "psr-4": {
        "App\\": "src"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Test\\": "tests",
        "Cake\\Test\\Fixture\\": "./vendor/cakephp/cakephp/tests/Fixture"
    }
},
"scripts": {
    "post-install-cmd": "App\\Console\\Installer::postInstall"
},
"config" : {
    "bin-dir" : "bin"
},
"minimum-stability" : "dev",
"prefer-stable": true

}

The plugin was installed in vendor/imagine/imagine/

I don't know what I am doing wrong. I have never used composer before that. So I'm not sure what I have written in the composer.json file. Someone can help me ?

Regards,

Snoopy


Solution

  • You're not using the plugin but accessing the vendor lib directly by what you're doing. Technically you can include the Imagine lib directly instead of the plugin via composer the way you do it.

    You're not getting any benefit from the plugin this way. Look at the behavior instead. I can't admit that the documentation could be better but hey, it's open source and done for free in my free time. The behavior code is pretty clear and you should immediately see how to utilize it.

    But actually the Basic-Example.md contains an example that shows how to use it.

    Finally, Ndm is right, the error is pretty clear:

    Error: Imagick not installed

    Install Imagick, your php installation is missing that module. That is not a problem of the plugin but your php installation.