我使用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 / imag / imag /
中我不知道我做错了什么。在此之前我从未使用过作曲家。所以我不确定我在composer.json文件中写了什么。有人可以帮帮我吗?
此致
史努比
答案 0 :(得分:0)
您不使用该插件,但直接通过您正在进行的操作访问供应商lib。从技术上讲,你可以直接包含Imagine lib,而不是通过composer来插入插件。
您不会以这种方式从插件中获得任何的好处。改为看一下行为。我不能承认文档可能更好但是嘿,它是开源的并且在我的空闲时间免费完成。行为代码非常清楚,您应该立即了解如何使用它。
但实际上Basic-Example.md包含一个显示如何使用它的示例。
最后,Ndm是对的,错误非常清楚:
错误:未安装Imagick
Install Imagick,您的php安装缺少该模块。这不是插件的问题,而是你的php安装。
答案 1 :(得分:0)
感谢您的回答。这是我第一次使用php composer,我认为我使用composer.json文件时出错了。我没想到它只是一个安装库。
所以现在我安装了Imagick,效果很好。
由于