notmii
notmii

Reputation: 413

Custom installation path for composer packages

Hi I am trying to setup a project using composer. I am able to install CakePHP but I am getting a hard time installing cakephp/debug_kit on a custom direcoty. I am trying to install it on "vendor/cakephp/cakephp/app/Plugin/DebugKit/" because CakePHP require its plugins to be installed on the Plugin directory of its "app" folder.

I already setup my composer.json according this site but still the plugin get installed on "vendor/cakephp/debug_kit"

Here is my composer.json maybe there is something wrong with my code. I am just a newbie in using composer.json.

{
    "name" : "notmii/pse",
    "repositories" :
    [{
        "type": "package",
        "package":
        {
            "name" : "cakephp/cakephp",
            "version" : "2.3.5",
            "source" :
            {
                "type" : "git",
                "url" : "git://github.com/cakephp/cakephp.git",
                "reference" : "2.3.5"
            },
            "bin" : ["lib/Cake/Console/cake"]
        }
    },
    {
        "type": "package",
        "package":
        {
            "name" : "cakephp/debug_kit",
            "version" : "2.2.0",
            "source" :
            {
                "type" : "git",
                "url" : "https://github.com/cakephp/debug_kit.git",
                "reference" : "2.2.0"
            }
        }
    }],

    "extra":
    {
        "installer-paths":
        {
            "vendor/cakephp/cakephp/app/Plugin/DebugKit/": ["cakephp/debug_kit"]
        }
    },

    "require" :
    {
        "php": ">=5.3",
        "cakephp/cakephp" : ">=2.3.5",
        "cakephp/debug_kit": "2.2.*"
    }
}

Upvotes: 5

Views: 6910

Answers (4)

Tomasz Kuter
Tomasz Kuter

Reputation: 666

I would recommend to use oomphinc/composer-installers-extender project.

More about this project you can find on GitHub project page: https://github.com/oomphinc/composer-installers-extender

Here is my configuration for Moodle:

{
  "name": "evolic/e-learning",
  "license": "MIT",
  "type": "project",
  "description": "e-Learning application",
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/moodle/moodle.git"
    }
  ],
  "require": {
    "php": "^8.2",
    "ext-json": "*",
    "ext-zip": "*",
    "moodle/moodle": "v4.2.1",
    "composer/installers": "^2.2",
    "oomphinc/composer-installers-extender": "^2.0"
  },
  "scripts": {
    "auto-scripts": {
      "create symlinks": "scripts/create-symlinks.sh"
    },
    "post-install-cmd": [
      "@auto-scripts"
    ],
    "post-update-cmd": [
      "@auto-scripts"
    ]
  },
  "extra": {
    "installer-types": ["project"],
    "installer-paths": {
      "public/": ["moodle/moodle"]
    }
  },
  "config": {
    "allow-plugins": {
      "composer/installers": true,
      "oomphinc/composer-installers-extender": true
    }
  }
}

Upvotes: 0

trank
trank

Reputation: 1012

If you want to add all plugins to app/Plugin instead of defining custom path for each plugin, update your extra block like this:

"extra": {
    "installer-paths": {
        "app/Plugin/{$name}/": ["type:cakephp-plugin"]
    }
}

Upvotes: 1

Farhan Wazir
Farhan Wazir

Reputation: 31

Composer Packages Custom Installer plugin, you don't need to develop custom installer. Just FORK it and add your instructions in config directory under src/Installer CPCInstaller will do everything for you.

Upvotes: 0

Kris
Kris

Reputation: 667

Change your extra block to:

"extra":
{
    "installer-paths":
    {
        "app/Plugin/DebugKit": ["cakephp/debug_kit"]
    }
},

This worked for me.

Upvotes: 10

Related Questions