Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install CakePHP Plugin and Helper via Composer

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.

like image 472
Kris Avatar asked Dec 27 '22 02:12

Kris


1 Answers

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.*"
          }
        }
like image 108
José Lorenzo Rodríguez Avatar answered Jan 05 '23 15:01

José Lorenzo Rodríguez