-2

我使用 cakephp 3.0.x-dev,我想使用插件 cakephp-imagine-plugin ( https://github.com/burzum/cakephp-imagine-plugin/tree/3.0 )。

当我使用这个插件时,我的 cakephp 视图中出现以下错误

错误:未安装 imagick

我的控制器看起来像

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);
   }
}

感谢 php composer.phar,我已经安装了插件视图。composer.json 文件如下所示:

 {
"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

}

该插件安装在 vendor/imagine/imagine/

我不知道我做错了什么。在此之前我从未使用过作曲家。所以我不确定我在 composer.json 文件中写了什么。有人可以帮助我吗?

问候,

史努比

4

2 回答 2

0

没有使用插件,而是通过您正在做的事情直接访问供应商库。从技术上讲,您可以通过 composer 直接包含 Imagine lib 而不是插件,就像您执行此操作一样。

通过这种方式,您不会从插件中获得任何好处。而是看行为。我不能承认文档可能会更好,但是嘿,它是开源的,并且在我的空闲时间免费完成。行为代码非常清晰,您应该立即了解如何使用它。

但实际上 Basic-Example.md 包含一个说明如何使用它的示例。

最后,Ndm 是对的,错误很明显:

错误:未安装 imagick

安装 Imagick,您的 php 安装缺少该模块。那不是插件的问题,而是您的php安装问题。

于 2014-10-21T18:38:50.663 回答
0

感谢您的回答。这是我第一次使用 php composer,我认为我在 composer.json 文件中犯了一个错误。我不认为它只是一个要安装的库。

所以现在我已经安装了 Imagick,它运行良好。

谢谢

于 2014-10-21T19:20:48.653 回答