I was using Pantheon's Drupal 8 upstream for a project, but wanted to switch to their composer based one instead. We are well into development of a customized Drupal Commerce site, so there was some trial and error to get the site to move over. I had some modules added without using composer, so I had to be careful to re-use the existing site root instead of re-compiling completely via composer.
First, I switched my docroot in my local and development hosting.
Lando (.lando.yml):
config:
webroot: root
Pantheon (pantheon.yml):
web_docroot: true
Then I created the web directory and moved existing files and directories:
mkdir web
mv android-chrome-* autoload.php browserconfig.xml core/ favicon* .htaccess index.php libraries/ modules/ mstile-150x150.png profiles/ robots.txt safari-pinned-tab.svg sites/ themes/ update.php web/
I had a few extra files, you can probably get away with:
mv index.php modules/ themes /libraries/ web/
Then I modified composer.json for the new path:
"installer-paths": {
- "core": ["type:drupal-core"],
- "modules/contrib/{$name}": ["type:drupal-module"],
- "profiles/contrib/{$name}": ["type:drupal-profile"],
- "themes/contrib/{$name}": ["type:drupal-theme"],
+ "web/core": ["type:drupal-core"],
+ "web/modules/contrib/{$name}": ["type:drupal-module"],
+ "web/profiles/contrib/{$name}": ["type:drupal-profile"],
+ "web/themes/contrib/{$name}": ["type:drupal-theme"], "drush/contrib/{$name}": ["type:drupal-drush"],
"drush/contrib/{$name}": ["type:drupal-drush"],
Then I removed composer.lock and re-installed (this will reinstall/update your dependencies):
rm composer.lock
lando composer install --no-dev
I run composer through Lando to make sure I use the right version of PHP.
Fix autoload.php (add /.. to /vendor/autoload.php location:
return require __DIR__ . '/../vendor/autoload.php';
That's it, after a cache clear everything is working.