Loading...


Related Products


Date Published: April 28, 2022

How to create a site using the latest version of Drupal and Composer

Creating a new Drupal website on Acquia Cloud Platform

Before you begin, make sure you have Composer and Git installed in your development environment (e.g. your laptop or Cloud IDE). You can then follow these steps to get a new Drupal website onto Acquia Cloud Platform

1. Clone your Acquia repository into a new folder like ProjectName and create a new branch:

git clone [email protected]:Sitename.git ProjectName
cd ProjectName
git checkout -b MyBranchName
2. Create a composer.json and composer.lock (be sure to include the dot at the end):
composer create-project --no-install drupal/recommended-project .
3. Modify composer.json by replacing web with docroot. You can use your preferred editor or run the following bash command:
sed -i'.original' 's/web\//docroot\//g' composer.json

4. Add the asset-packagist.org as an additional repository to provide access to supplement packages.drupal.org and provide access to additional packages:

composer config repositories.1 composer https://asset-packagist.org

5. Configure the location and name of the vendor directory:

composer config vendor-dir vendor

6. Select your preferred installation type (options are source, dist or auto):

composer config preferred-install dist

7. Add the following useful projects:

composer require drush/drush:^10.0 --no-update
composer require drupal/stage_file_proxy --no-update
composer require cweagans/composer-patches --no-update

8. (Optional) Add the following in the section labeled extra in your composer.json for future patches. You can read Patching with Composer for more details. Include these lines if you have a patch (to core or a module) that needs to be added (note the following instruction to ignore patch failures):

"enable-patching": true,
"patches": {
  "drupal/[module_name]": {
    "Note regarding the nature of the patch being applied": "https://www.drupal.org/files/issues/[patch_name].patch"
  }
},

9. Configure Composer to continue if a patch fails:

composer config extra.composer-exit-on-patch-failure false

10. Add the following after the section labeled extra in your composer.json. These scripts will remove .git folders after each update to make sure git is tracking all files:

"scripts": {
  "post-install-cmd": [
    "find docroot vendor -name '.git' | xargs rm -rf",
    "find docroot vendor -name '.github' | xargs rm -rf"
  ],
  "post-update-cmd": [
    "find docroot vendor -name '.git' | xargs rm -rf",
    "find docroot vendor -name '.github' | xargs rm -rf"
  ]
}

11. Run the following Composer command to install all dependencies:

composer install

12. Now you need to add your database connection. Copy default.settings.php over to settings.php. Then modify the settings.php file by following the instructions on the Acquia require line documentation page:

cp docroot/sites/default/default.settings.php docroot/sites/default/settings.php

13. Add the following to your settings.php for configuration management:

$settings["config_sync_directory"] = $app_root . '/../config/' . basename($site_path);

14. Add and commit your code:

git add .
git commit -m "Initial commit of new Drupal core site."

15. Push your changes to the Acquia repo. Run the following command and it will create a new tracking branch on the remote repo:

git push --set-upstream origin MyBranchName

16. Go to your Acquia Cloud and switch the code to your branch on your preferred testing environment (e.g. test or dev).

 

17. Now you need to go to the site page and follow Drupal installation steps.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation