So I've been going through the steep learning curve from D7 to D9.

I like to use git for deployment and version control. I'm new to composer as I only know Drupal and it was never used.

I've developed the whole website using composer and drush on my local machine. Namely composer require drupal/[modulename] && drush en [modulename]-y

I moved the example.gitignore file from the web directory to the base as .gitignore. Updated the paths to reflect the move.

Without the comments it contain this:


Having completed the website I ran the usual commands on my local copy.

drush cex && git add . && git commit -m "Some commit message" && git push origin master

On my server I pulled the code down and imported my database. I read that I then run composer install.

After that, my contrib module patches were overridden? I'm guessing that the composer install command grabs fresh copies of everything?

What then is the correct method?

  • 2
    You wouldn't run composer in production. You would either push the entire artifact to the cloud, or have a continuous integration service build the code and deploy for you.
    – Kevin
    Jun 7, 2022 at 21:20
  • So I would remove web/core & vendor from my .gitignore. Never use composer in production. Then I'm good to go?
    – gMaximus
    Jun 7, 2022 at 21:24
  • 2
    You also apply patches via Composer. Some people do run composer install on prod. What Kevin talks about are advanced deployment strategies.
    – leymannx
    Jun 7, 2022 at 22:40
  • 2
  • 1
    This tutorial I wrote on Composer may help: morpht.com/blog/…. It's slightly outdated (I don't work at the place to be able to update it), but mostly still relevant, and written for people new to using Composer with Drupal.
    – Jaypan
    Jun 8, 2022 at 0:58


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.