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
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.
- 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.
- Running composer directly on a Pantheon site 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.
- Another example that works: