Reputation: 667
I want to install the following plugin and helper via 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"
}
}
}
The packages are successfully installed at Vendor/cakephp/debug_kit and Vendor/loadsys/twitter-bootstrap-helper
My issues lies in how to I load them in CakePHP. I have the following in my bootstrap.php:
require APP . 'Vendor/autoload.php';
When I attempt to load the Plugin after requiring the autoload with:
CakePlugin::load('DebugKit');
It can not be found. Similar results with loading the helper in my AppController.php with
public $helpers = array('TiwtterBootstrap');
I am a newbie to Composer and am likely missing something simple or just not grasping how to properly load them from the Vendors folder.
Upvotes: 4
Views: 4327
Reputation: 667
I was rushed this morning in my comment, here is the "extra" block I added to my composer.json:
"extra": {
"installer-paths": {
"Plugin/DebugKit": ["cakephp/debug_kit"],
"Plugin/TwitterBootstrap": ["loadsys/twitter-bootstrap-helper"]
}
Deleting my composer.lock in order to start over with the install, still didn't put the files into the Plugin folder. However, even if I got that to work, I thought it would be possible for the system to recognize the plugins from the Vendor folder via the composer autoload and perhaps some magic from Cake. That way I could just keep the entire Vendors folder out of my repository for this project and update my dependencies as needed.
I ended up solving my issue by just sym linking to these files from the Plugin folder and my system is recognizing the Plugins.
Upvotes: 0
Reputation: 9614
Everything you have done is correct, you just need to add an extra section to instruct composer where to install your plugin. Note the extra "installer-paths" sections , it needs to point to the relative path where you want you plugin be installed.
{
"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.*"
}
}
Upvotes: 10