Brett
Brett

Reputation: 20049

Utilising composers asset-installer-paths not working

I'm trying to install a certain package in composer into a certain path, the package name is cyphix333/nbbc and normally it would be installed into vendor/cyphix333/nbbc however I wanted to install it into vendor/nbbc so I tried this in the main project composer.json

"require": {
    //......
    "cyphix333/nbbc": "dev-master"
},

"extra": {
    "asset-installer-paths": {
        //.....
        "cyphix333/nbbc": "vendor/nbbc"
    }
}

However it didn't work, it still installed into vendor/cyphix333/nbbc.

Edit: ...and here is the full data from the extra part, which comes from my php framework yii2:

"extra": {
    "yii\\composer\\Installer::postCreateProject": {
        "setPermission": [
            {
                "runtime": "0777",
                "web/assets": "0777",
                "yii": "0755"
            }
        ],
        "generateCookieValidationKey": [
            "config/web.php"
        ]
    },
    "asset-installer-paths": {
        "npm-asset-library": "vendor/npm",
        "bower-asset-library": "vendor/bower",
        "cyphix333/nbbc": "vendor/nbbc"
    }
}

What am I doing wrong here?

Upvotes: 1

Views: 1560

Answers (1)

Jens A. Koch
Jens A. Koch

Reputation: 41766

1. asset-installer-paths = Composer plugin fxp/composer-asset-plugin

The asset-installer-paths directive belongs to the Composer plugin fxp/composer-asset-plugin. The plugin is required, for this directive to work. But you are not requiring it in your project repo or globally.

Docu - Installation

composer require "fxp/composer-asset-plugin:~1.0"

or

composer global require "fxp/composer-asset-plugin:~1.0"

2. Is cyphix333/nbbc a Bower or NPM asset?

No.

3. What am I doing wrong here?

You think, that you can use asset-installer-paths directive to move your package to a specific folder. You can't. Because your repo is not an Bower or NPM asset.

4. How can i move my package from vendor/cyphix333/nbbc to vendor/nbbc?

Stop trying that. It's wasted time. Why? Composer has an Autoloader and he does the mapping from classname to filename. Please do not care about the path, just define an autloading strategy (files or classmap) and start using your class.

If you really need to copy stuff, you might use the scripts section of your composer.json. https://getcomposer.org/doc/articles/scripts.md

Upvotes: 4

Related Questions