Skip to content

upsun/drupal-scaffold

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Upsun+Drupal Composer Scaffold

This project provides a composer plugin for placing scaffold files (like .upsun/config.yaml, settings.platformsh.php, …) into their desired location within an existing Drupal project to make it work on Upsun hosting.

Usage

Upsun-Drupal Composer Scaffold is applied by requiring upsun/drupal-scaffold in your project, and adding it to the list of drupal-scaffold.allowed-packages

Once installed, the scaffold operations run automatically as needed, e.g. after composer install.

Installation

To add this feature to an existing Drupal project that was built in the recommended-project structure,

composer config repositories.upsun-drupal-scaffold vcs https://github.com/upsun/drupal-scaffold
composer config --json --merge extra.drupal-scaffold.allowed-packages '["upsun/drupal-scaffold"]'
composer require upsun/drupal-scaffold

There are minor variations in the scaffolding files between different versions of Drupal. This project repository supplies different version branches and publishes different constraints that composer will use to automatically resolve which version of the scaffolding should be used.

Add the new files to your project.

The scaffolding files added by this process must now be added to your project via git add as they are required to be part of the repository branch that is uploaded to the Upsun server. Some of these files (config.yaml) must exist and have been committed before the push to the Upsun environments can be validated.

What the scaffolding addition does

  • Adds required Upsun config file config.yaml
    • which defines the database services, web behaviour, and deployment actions
  • Adds configurations to settings.php to use the environment settings.
    • Such as the DB connection details
  • Adds drush support with some helper scripts and environment variables
    • .environmnent
  • Requires drush/drush and drupal/redis libraries for optimal behaviour.

Adjustments

Review the docs for troubleshooting tips

If you used the Drupal recommended-project as a starter, then your web-root inside your project will be web/. This is the assumed default. Your current Drupals composer.json may include the section that looks like this:

    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"

If your project is structured a little differently, using docroot or public as the web-root, then you should adjust the provided scaffold file .upsun/config.yaml accordingly, replacing most instances of web/ with your actual web-root path. Importantly, the applications.drupal.web.locations./.root value. and also applications.drupal.mounts."/web/sites/default/files"

Places to look:

yq '.applications.drupal.web.locations./.root' < .upsun/config.yaml
yq '.applications.drupal.mounts | keys' < .upsun/config.yaml

Deploy

Once the drupal-scaffold changes have been added to your repository, your project should be ready to push into an Upsun project and begin working.

If you don't have an Upsun project created already, then you'll have to create a project either through the console or the CLI.

Gotcha: Use the right subscription plan.

Note, if creating your project, do not use the development subscription plan. It must be upsun/flexible or you won't get any resources to begin with.

If you are on the wrong plan, need to update things before pushing successfully/

upsun resources:get
upsun subscription:info plan 'upsun/flexible'
upsun resources:set --disk drupal:512,db:614512

CHANGELOG

The x.1.x releases introduce some cleanup and removes some code that is infrequently used.

  • The platformsh/config-reader dependency is removed. Database connection details are now retrieved directly from the environment.
  • The generate_drush_yaml script is removed from the build hook. drush URI is now configured by means of an envirnment variable defined in the .environment file
  • Drupal-specific environment variable support is removed from settings. It is very seldom used, and can be applied manually if anyone wants to use it.
  • Static files cache lifetime has been bumped up to 6 minths, as the previous short lifetime was a development-only default, not a recommendation for production.

About

Configuration additions to add Upsun hosting capabilities to an existing Drupal project

Resources

Stars

Watchers

Forks

Packages

No packages published