Composer is a tool for managing PHP dependencies for your website or application.
To install Composer for use with your website, complete the following steps:
- Download Composer from its download page.
- To allow you to install Composer, depending on your operating system, download and install the appropriate package manager using the instructions on its download page:
- Open a command prompt window.
- Install Composer using the appropriate command, based on your operating system:
brew install composer
scoop install composer
- If you are using Composer locally, update the
.gitignoreto allow you to commit changes to your
Using Composer with Acquia Cloud
Because Composer is not installed on Acquia Cloud, we recommend that you install Composer locally and use it with your local copy to perform updates and and manage dependencies. You can then deploy your code to your Acquia Cloud environments.
It is also possible to install Composer in Acquia Cloud, but to do so you will need to both enable Live Development and follow normal Git workflow for checking out the code (including adding the changed flags, committing the changes, and pushing to origin).
After installing Composer, using Composer on Acquia Cloud requires Live Development mode to be enabled. For more information about working with Live Development, see Live Development workflow.
By default the
.gitignore file ignores the
Vendor directory, which makes sense if you are using Composer on Acquia Cloud directly.
Using Composer with Drupal 8.0.x
If you are using Drupal versions less than version 8.1, you can install the Composer Manager module to help you manage Composer's
composer.json files. We recommend that you follow the recommended settings on the Composer Manager for Drupal 6 and Drupal 7 page on Drupal.org, and then apply the recommended settings from the Production Environments section of the same page.
For more information about this process, see the Using Composer Manager to get off the Island Now blog post from Acquia.com's Developer website.
Using Composer with Drupal 8.1 and greater
Starting with Drupal 8.1, Drupal core directly uses Composer to manage dependencies, which can include Drupal modules. Instead of using the Composer Manager module, the recommended workflow for a module with Composer dependencies is to require the module itself through Composer. For more information, see the following Drupal.org resources: