Cakephp 3 how to use plugins (Imagine)

In my cake app a need Imagine but how I can create instance of class Imagine in Controller.

Plugin was install by composer and all files are in vendor folder.

This: require ‘vendor/autoload.php’; $imagine = new Imagine\Gd\Imagine();

doesn’t work.

I get:

require(vendor/autoload.php): failed to open stream: No such file or directory [APP/Controller\ArticlesController.php, line 100] Fatal error: require() [function.require]: Failed opening required ‘vendor/autoload.php’ (include_path=‘C:\xampp\php\PEAR’) in C:\xampp\htdocs\cakephp_blog\src\Controller\ArticlesController.php on line 100

You shouldn’t need to re-include your vendor/autoload.php file. If you’ve installed Imagine with composer and re-built your autoloader you should be able to do

$imagine = new \Imagine\Gd\Imagine();

If you want to ensure your autoloader is fresh, you can do

php composer.phar dumpautoload
1 Like