1

How to place git repo to a custom path? I am using composer/Installer. and I have develop a module on git repo. I would like to add it to composer.json but after pull it should be placed web/modules/custom directory. How can i do that.

I added this parts in my composer.json

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/miteshmap/axelerant_custom"
    }
],

"require": {
    "miteshmap/axelerant_custom": "*"
},
"extra": {
    "installer-paths": {
        "web/core": ["type:drupal-core"],
        "web/modules/contrib/{$name}": ["type:drupal-module"],
        "web/modules/custom/{$name}": ["type:drupal-module"],
        "web/profiles/contrib/{$name}": ["type:drupal-profile"],
        "web/themes/contrib/{$name}": ["type:drupal-theme"],
        "drush/contrib/{$name}": ["type:drupal-drush"]
    }
}

2 Answers 2

0
"require": {
    "composer/installers": "dev-master",
    "miteshmap/axelerant_custom": "*"
},
"extra": {
    "installer-paths": {
        "web/core": ["type:drupal-core"],
        "web/modules/contrib/{$name}": ["type:drupal-module"],
        "web/modules/custom/{$name}": ["type:drupal-custom-module"]
        "web/profiles/contrib/{$name}": ["type:drupal-profile"],
        "web/themes/contrib/{$name}": ["type:drupal-theme"],
        "web/themes/custom/{$name}": ["type:drupal-custom-theme"]
        "drush/contrib/{$name}": ["type:drupal-drush"],
    }
}

We can do that when composer/installers have defined the type and for that a request was merged with master here - https://github.com/composer/installers/pull/269

And to add the new merge of composer/installers into your json. you can update the composer.json as per the The solution proposed here - https://github.com/drupal-composer/drupal-project/pull/118. The same is explained in above code.

0

Using davidbarratt/custom-installer you can simply install any repo you want into any custom location you want by assigning it a totally custom type. In the sample below I used the custom types "type": "foo-bar-foo" and "type": "bar-foo-bar" to install two repos into two different custom locations.

Here's a working sample composer.json:

{
    "name": "myproject",
    "description": "myproject description",
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "select2",
                "version": "4.0.3",
                "type": "foo-bar-foo",
                "source": {
                    "url": "https://github.com/select2/select2.git",
                    "type": "git",
                    "reference": "tags/4.0.3"
                }
            }
        },
        {
            "type": "package",
            "package": {
                "name": "scrollmagic",
                "version": "v2.0.5",
                "type": "bar-foo-bar",
                "source": {
                    "url": "https://github.com/janpaepke/ScrollMagic.git",
                    "type": "git",
                    "reference": "tags/v2.0.5"
                }
            }
        }
    ],
    "require": {
        "davidbarratt/custom-installer": "^1.0@alpha",
        "scrollmagic": "^2.0",
        "select2": "^4.0"
    },
    "extra": {
        "custom-installer": {
            "foo-bar-foo": "web/themes/custom/mytheme/lorem-ipsum/{$name}",
            "bar-foo-bar": "web/themes/custom/mytheme/dolor-sit-amet/{$name}"
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.