Nasser Ali Karimi
Nasser Ali Karimi

Reputation: 4663

composer to install a package or module in a custom path?

I have tried to install a Drupal module with the composer in a specific path,

I check these links but I can't figure out that.

Please check this and tell me what is wrong and what I should do?

What do I want?

Install the Signature field module in the modules/patched directory.

this is part of my composer.json file that is related to this issue.

"require": {
    "composer/installers": "^1.0.24",
    "drupal/signature_field": "^1.0@RC",
},

    "installer-paths": {
        "core": ["type:drupal-core"],
        "modules/contrib/{$name}": ["type:drupal-module"],
        "profiles/contrib/{$name}": ["type:drupal-profile"],
        "themes/contrib/{$name}": ["type:drupal-theme"],
        "drush/contrib/{$name}": ["type:drupal-drush"],
        "modules/custom/{$name}": ["type:drupal-custom-module"],
        "themes/custom/{$name}": ["type:drupal-custom-theme"],
        "modules/patched/{$name}": ["type:drupal-patched-module"]
    },
    "patches": {
        "drupal/signature_field": {
            "Drupal Signature Field fix multi feilds": "modules/patched/signature_field/signature_field-2993223-08.patch"     
        }
    }
},

At the end I do composer install and composer update, but the module doesn't transfer to the folder that I want

Upvotes: 3

Views: 1513

Answers (2)

Nasser Ali Karimi
Nasser Ali Karimi

Reputation: 4663

there we should define the custom path and defining that which module or package should install in that path.

like this

"installer-paths": {

    // custom path with the list of items that should installed there.

    "modules/patched/{$name}": [
        "drupal/signature_field",
        "drupal/eck",
        "drupal/auto_entitylabel"
    ],
}

The package or module should be in your require section as well.

"require": {
        "composer/installers": "^1.0.24",
        "drupal/auto_entitylabel": "2.x-dev",
        "drupal/signature_field": "^1.0@RC",
        "drupal/eck": "^1.0@alpha",
}

Upvotes: 1

Tarasovych
Tarasovych

Reputation: 2398

Maybe this could help (note about extra):

{
    "extra": {
        "installer-paths": {
            "modules/patched/{$name}": ["drupal/signature_field"],
            "modules/patched/{$name}": ["another/package"]
        }
    }
}

Reference, GitHub comment

Probably, this'd work:

{
    "extra": {
        "installer-paths": {
            "modules/patched/{$name}": ["drupal/signature_field"]
        }
    },
    "extra": {
        "installer-paths": {
            "modules/patched/{$name}": ["drupal/another_module"]
        }
    }
}

or

{
    "extra": {
        "installer-paths": {
            "modules/patched/{$name}": ["drupal/signature_field"]
        },
        "installer-paths": {
            "modules/patched/{$name}": ["drupal/another_module"]
        }
    }
}

Also,

You cannot use this to change the path of any package. This is only applicable to packages that require composer/installers and use a custom type that it handles.

You can also group your packages by type:

{
    "extra": {
        "installer-paths": {
            "your/custom/path/{$name}/": ["type:wordpress-plugin"]
        }
    }
}

or certain vendor:

{
    "extra": {
        "installer-paths": {
            "your/custom/path/{$name}/": ["vendor:drupal"]
        }
    }
}

Upvotes: 1

Related Questions