There is a module that I frequently post patches for and use the latest development version. I have created a composer.json that includes:

"repositories": [
    "type": "path",
    "url": "web/modules/custom/*"
... and later ...
"require": {
  "drupal/THEMODULE": "*",

The git repository for THEMODULE resides at web/modules/custom/THEMODULE. Locally I manage the repository there, pushing, pulling, and creating patches. Then for production, I push to the production server and a git post-receive hook copies the code to the same directory on the server.

But now I want to stop using git to push to production and instead use composer to specify a particular version/release/commit and use cweagan/composer-patches to specify the patches I want for production.

I have committed both composer.json and composer.lock to git so that I can push the specifications I want for production and then just run 'composer install' (rather than composer update) on the server. This re-creates the environment I'm using in development. I would like to avoid running 'composer update' on the server for fear it will create regression that I haven't tested in dev or staging.

I know that you can use "require-dev" to ADD additional resources, but what I really want is to keep my custom modules repository (for my custom module) but for production to NOT use the custom modules repo, but rather the packages.drupal.org repo. And for local dev, I want the opposite: use the local modules/custom repo and not packages.drupal.org

What are other people doing for modules that you keep in git locally but want deployed from official repos for production?

  • 2
    I keep no modules in git except custom modules that live nowhere but the project. You can sidestep a lot of this by utilizing the patches aspect of composer-patches and building the project in a service like Circle, Travis, GitLab CI or Jenkins, and deploying the result to your server (no need to composer install in production). You should make the full switch to composer. I am not really clear on why you need a local repo entry pointing at a local directory for Composer?
    – Kevin
    Commented Feb 10, 2020 at 23:22
  • @Keven - Thanks. The root of the issue is that I'd like to use patches and composer for production, but git for local. Locally, I check out commits and test them and generate patches and issue branches to contribute on the issue queue at drupal.org -- all of which I use git for. The problem is then I have two different composer.json files and I'm not accurately replicating the production environment on dev. My own custom module lives in git both on production and dev and isn't the problem. Commented Feb 12, 2020 at 0:56


Your Answer

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

Browse other questions tagged or ask your own question.