Install CakePHP plugin and helper through composer

I want to install the following plugin and helper through Composer:

https://github.com/cakephp/debug_kit https://github.com/loadsys/twitter-bootstrap-helper 

Here is my composer .json:

 { "repositories": [ { "type": "package", "package": { "name": "cakephp/debug_kit", "version": "2.0", "source": { "url": "https://github.com/cakephp/debug_kit", "type": "git", "reference": "origin/2.0" } } }, { "type": "package", "package": { "name": "loadsys/twitter-bootstrap-helper", "version": "2.1", "source": { "url": "https://github.com/loadsys/twitter-bootstrap-helper", "type": "git", "reference": "origin/2.1" } } } ], "require": { "loadsys/twitter-bootstrap-helper": "2.1.*", "cakephp/debug_kit": "2.0" }, "config": { "vendor-dir": "Vendor/" }, "autoload": { "psr-0": { "DebugKit": "/cakephp/debug_kit/", "TwitterBootstrap" : "/loadsys/twitter-bootstrap-helper" } } } 

Packages successfully installed in Vendor / cakephp / debug_kit and Vendor / loadys / twitter-bootstrap-helper

My problems are how to upload them to CakePHP. In my bootstrap.php there is the following:

 require APP . 'Vendor/autoload.php'; 

When I try to download a plugin after an autoload request with:

 CakePlugin::load('DebugKit'); 

Unable to find. Similar results with loading assistant in my AppController.php using

 public $helpers = array('TiwtterBootstrap'); 

I am new to Composer and probably missed something simple or just didn't understand how to properly load them from the Vendors folder.

+4
source share
2 answers

All that you have done correctly, you just need to add an additional section to instruct the composer where to install the plugin. Pay attention to the additional sections "installation paths", it should indicate the relative path in which you want to install the plugin.

  { "minimum-stability": "dev", "config": { "vendor-dir": "vendors" }, "extra": { "installer-paths": { "app/Plugin/DebugKit": ["cakephp/debug_kit"], } }, "require" : { "php": ">=5.4", "cakephp/debug_kit": "2.2.*" } } 
+10
source

I was thrown this morning in my comment, here is the β€œextra” block that I added to my composer .json:

  "extra": { "installer-paths": { "Plugin/DebugKit": ["cakephp/debug_kit"], "Plugin/TwitterBootstrap": ["loadsys/twitter-bootstrap-helper"] } 

Removing my composer.lock to start with the installation still did not put the files in the Plugin folder. However, even if I got this to work, I thought that the system would be able to recognize plugins from the Vendor folder through the composer's startup and possibly some kind of magic from Cake. That way, I could just save the entire Vendors folder from my repository for this project and update my dependencies as needed.

I decided to solve my problem by simply linking to these files from the Plugin folder, and my system recognizes plugins.

0
source

Source: https://habr.com/ru/post/1484108/


All Articles