How to update your Drupal 8 website to use the Composer Drupal project

Composer

How to update your Drupal 8 website to use the Composer Drupal project

Updating an existing Drupal 8 installation to a Composer installation is actually pretty easy. There are already a few scripts out there that will help you achieve this. By following this step to step guide you'll successfully update your Drupal 8 website to use composer.

  1. Create a new Composer project by executing
    composer create-project drupal-composer/drupal-project:8.x-dev my_project --stability dev --no-interaction
  2. Copy all your custom modules to your_project/web/modules/custom
  3. Copy all files added on your website. This is usually your_old_project/sites/default/files if you haven't configured a multi-site
  4. Copy all libraries you are using to your_project/web/libraries
  5. Now add all contrib modules used in your project to your composer.json by executing
    composer require drupal/machinename_contrib_module
  6. (Optional) Add all other composer compatible libraries you are using (composer require your/library)
  7. Copy your settings.php file to your_project/web/sites/default
  8. (Optional) If you are using GIT to manage your code, at this point you can copy all the files and directories in the root folder of your new project to your GIT directory and push the changes to your remote repository

You are now ready to start using Composer in your Drupal project. Happy coding!

Tags