Skip to content

Instantly share code, notes, and snippets.

@nadavoid
Last active November 7, 2016 20:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadavoid/04e44cbf78091caf68f2db0ae7e815f7 to your computer and use it in GitHub Desktop.
Save nadavoid/04e44cbf78091caf68f2db0ae7e815f7 to your computer and use it in GitHub Desktop.
Using composer to manage a single site build on Pantheon

This doc has been moved to my blog: https://www.davidlanier.com/blog/2016/11/using-composer-on-pantheon

I worked through https://pantheon.io/blog/using-composer-relocated-document-root-pantheon and chased a few rabbits, and ultimately landed on what I think a pretty simple workflow. The main thing I was interested in was how to use composer to effectively manage a drupal project on pantheon. Composer is practically required for building the codebase of Drupal 8 because there are so many external dependencies now. Composer handles downloading the right versions of all packages.

The main steps:

  • Create a new site at pantheon, selecting "Drops 8 Composer"
  • Install site using the UI.
  • Switch to git mode.
  • Clone pantheon repo locally.
  • Use composer locally to add additional modules and packages.
  • Commit updates to composer.json, composer.lock, AND the build/downloaded packages.
    • Delete any .git directories that composer added because of checkouts, before committing downloaded packages. If you don't, git will see them as subprojects, which are unsupported on Pantheon.
  • Commit custom code in modules/custom and themes/custom.

This ignores pantheon "upstreams" of any sort. When a new drupal core release comes out, running composer update drupal/core will get it. Same type of thing with drupal modules.

More options:

  • Use a separate repo for custom code and set up composer.json to use it.
  • Keep a separate, slim repo with only the composer files, not the installed codebase.
    • Cleaner separation of source files and built out codebase.
    • More complexity in code management, because an additional repo or branches would be needed for tracking the built out codebase.
  • Create a custom upstream to deploy updates.
    • Adds a step to deploys.
    • Does not change how you assemble the codebase.
    • Probably not worth the extra effort for a single site.

More notes:

  • Running composer directly on a Pantheon site instead looks interesting.
    • The composer binary is available on pantheon; you just need a plugin of some sort to use it.
    • Can use terminus plugin rvtraveller/terminus-composer.
    • Is there a drush plugin that would work?
    • One example that works: web/private/scripts/deploy_product/composer-install.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment