Figuring out how to use the Composer package manager to handle your project's dependencies can be a bit tricky. Using the Drupal Composer Project as a starting point provides you with an opinionated (and Drupal-aware) starting point. This project provides help with many of the common initial project setup tasks including the installation of tools like Drush, as well as setting the correct file permissions required to actually install Drupal.
Note: As of Drupal 8.8.0, the recommended Composer template is the "officially supported" drupal/recommended-project. There are other popular "templates" for starting a new Drupal application with Composer, including drupal-composer/drupal-project. You can find the full list in Using Composer to manage Drupal site dependencies on Drupal.org.
Example tasks
- Use a common scaffold tool for new project setup
- Leverage Composer to manage all of the dependencies of the codebase
- Start each new project with the most recent Drush and Drupal Console versions ready to go
- Manage the Drupal core update process more easily
Confidence
The Drupal Composer project provided a stop-gap in managing Drupal sites with Composer for most of Drupal 8's lifecycle. While this project still exists and may be used, the Drupal project now provides its own "recommended-project" Composer template which is the current recommendation for setting up Drupal sites for development.
Drupalize.Me resources
More information
When managing your Drupal project with Composer you'll use Composer commands to download (require) modules and themes that you want to install, as well as issuing commands to keep those modules and themes up-to-date when new versions are released.
In this tutorial we'll:
- Cover step-by-step instructions for performing common Composer tasks for a Drupal application
- Install and update Drupal projects (core, modules, themes, profiles, etc.) using Composer
- Convert an existing application to use Composer
By the end of this tutorial you should know how to use Composer to install, and update, Drupal modules and themes.
More information
Drupal 8.8.0 introduced a bunch of new features intended to make it easier over the long-term to maintain a Drupal project using Composer. In doing so it establishes some new best practices, and moves into Drupal core solutions that were previously maintained by the community. This is all good news. But, it means if you're using Composer to update from Drupal 8.7.x or lower to 8.8.0 or higher you'll need to do a bit of additional work to untangle everything.
This tutorial is especially useful if you started your Drupal project using the drupal-composer/drupal-project
template and would like to convert to use the new templates (i.e. drupal/recommended-project
or drupal/legacy-project
) included with Drupal 8.8.x core.
In this tutorial we'll:
- Convert our project to use the new
drupal/core-recommended
, and drupal/core-dev
Composer packages
- Explain which commonly used Composer packages are deprecated, and which new ones replace them
- Learn how to use the
drupal/core-composer-scaffold
Composer plugin
- Cover tips for troubleshooting updates
Furthermore, in order to Upgrade to Drupal 9 from Drupal 8, you will first need to update your Drupal 8 site to at least version 8.8, as the upgrade paths for Drupal 8 site from before Drupal 8.8.0 have been removed from Drupal 9.
By the end of this tutorial you should be able to update your Drupal projects using Drupal core 8.7.x or lower to Drupal core 8.8.0 or higher using Composer. And be ready for an upgrade to Drupal 9.
More information
Composer is the preferred dependency management solution for PHP, is used by Drupal core, and is becoming increasingly popular for managing the modules and themes used for a Drupal project.
External resources