Drupal 8 composer-managed dev and deploy

Submitted by elli on Thu, 04/19/2018 - 18:05

Hiii! I'm just going to copy my notes on my workflow so far here so there's a bit of site content to work with. This is first attempt at really launching and working with my own Drupal site, so things are probably wrong and will break! Kindly if you have feedback ping me somewhere: twitter @ekl1773 or pm in Drupal slack (same username everywhere). You can comment here too but no guarantees! 

So, here's how I got to where I am right now, 6pm EST, April 19th 2018. 


Installed Lando for localhost


  1. Git for Drupal

  2. Server Provisioning

  3. Central repo on GitHub No reason for code to be that public (pfs)

    1. SSH keys

  4. Create central repo on remote server: git init --bare ELD8.git

  5. https://github.com/drupal-composer/drupal-project

    1. Create project with moshe's composer create-project drupal-composer/drupal-project:8.x-dev ELD8 --stability dev --no-interaction

  6. Git init - git to track my code, composer.lock. Composer to track versions/dependencies.

  7. https://www.lullabot.com/articles/drupal-8-composer-best-practices

  8. https://docs.devwithlando.io/tutorials/composer-tutorial.html

    1. Super useful guide. Lando init inside composer project dir, point to web dir for webroot

  9. Fix remote origin to point to dreamhost server ? tried...

  10. Composer show -i for installed packages - phpunit/phpunit is already there composer show phpunit/phpunit for details

  11. Managed to set up lando composer test with phpunit to run tests. Not sure if phpunit is --dev? Would like to find a way to search for just --dev dependencies. Just wanted to make something work! It was failing like below until I created a separate phpunit.xml file instead of the phpunit.xml.dist file.


lando composer test

> ./vendor/bin/phpunit || true

Could not load "/app/phpunit.xml".

Attribute bootstrap redefined


Would like to come back to this and understand the difference and why it works now, and why/if it's supposed to print the ./vendor line?


lando composer test

> ./vendor/bin/phpunit || true

PHPUnit 6.5.8 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Elli is a rockstar Drupalist.

  1. Ooo new info from Geerling and Grasmash!! https://grasmash.github.io/drupal-composer-training/#create-a-build-and-deploy-to-cloud-hosting

  2. Push local to central repo on dreamhost. Just had the path to repo.git wrong

  3. Cloning? to live- I think my thought is right, the composer project folder should be above my site root, so what's currently "web" will be "elliludwigson.com" with the vendor dir above that. Why was that so hard to find info on? Everyone else knows? + Changed web directory in dreamhost settings. https://github.com/drupal-composer/drupal-project/issues/258

git clone --branch [branchname] ssh://[username]@[mysite].com/~/[fooproject].git [mysite].com

  1. Put DB on remote server

  2. Don't do install on local? Or do install on local and only once on remote? "In Drupal 8 the site should be installed only once (rather than repeating the install for dev, staging and production sites), and the different versions of the site should be created with databases set up using a dump of the database from the first copy of the site."

  3. TODO:

  4. So I pull down my db (equiv of drush sql sync?) and then how do I get it into lando? https://www.drupal.org/docs/user_guide/en/install-dev-making.html

  5. Once you switch back to your master branch and want to do development work again, you can go ahead and run composer install without all these options and it will reinstall your require-dev dependencies.

  6. Modules

  7. Image Optimisation