phpcomposer-phppackagist

How to set the install directory for a package on the package, instead of on the project?


I am working on creating a custom composer package. The composer package must install to a custom folder instead of vendors/ directory I want it to be installed in packages/. This is how my composer.json looks like:

{
"name": "demo/contentfeed",
"description": "This is yet another Lumen composer package wrapper",
"type": "lumen-plugin",
"version": "1.1.5",
"keywords": ["demo","lumen","drupal"],
"homepage": "https://github.com/gauravmehrasrijan/lumen-feeds",
"require": {
    "composer/installers": "^1.0.24"
},
"autoload": {
    "psr-4": {
        "demo\\Contentfeed\\": "/src"
    }
},
"extra": {
    "installer-name": "packages",
    "installer-paths": {
        "packages": ["demo/contentfeed"]
    }
},
"license": "MIT",
"minimum-stability": "dev",
"authors": [
    {
        "name": "Gaurav Mehra",
        "email": "gauravmehra1987@gmail.com"
    }
]
}

Before jumping here I also tried the solution posted in this link but it didn't work for me, I added installer-name key in extra, but no success.


Solution

  • This is not possible, and the documentation says so explicitly:

    [...] The ability for a package author to determine where a package will be installed either through setting the path directly in their composer.json or through a dynamic package type: "type": "framework-install-here".

    It has been proposed many times. Even implemented once early on and then removed. Installers won't do this because it would allow a single package author to wipe out entire folders without the user's consent. That user would then come here to yell at us.

    (Emphasis mine)

    The two keys you are using (installer-paths and installer-name) serve a different purpose than what you imagine: