Composer Training

Composer is a command line dependency management tool for PHP. What does that mean? Well, in short, as we know Drupal is made of modules. Those modules will have security and functionality updates. And they are built in PHP. Composer is the tool we use to keep all of these modules (projects) to be kept up to date. 

This video is a good intro to the general use of composer in PHP projects. The same basic process that he discusses and demonstrates is the same process we use to install, remove and update composer. 

Go ahead and watch how he installs Composer, but DO NOT follow along. We have our own process to install Composer. 

When he talks about the Vendor directory and where Composer installs the composer.json and composer.lock files it is a little different in Drupal. Composer still uses these files, but as you can see in the image below it is in a different location. 

composer json and composer lock

Additionally, in the video when he talks about the package being download into the Vendor folder, Drupal acts a little differently with Composer. When we type "composer require drupal/<module name> that module (or sometimes called a project) gets downloaded into the Web>Module>Contrib folder. At the same time a require line gets added to the composer.json file. 


This is all kind of complicated, but once we do it a few times it will make sense to you. With that said, Composer is very useful and common with PHP applications. Just remember, at this point we are looking at you getting the big idea of Composer and not the details. We will work the details when we step, by step, go through updating a website. 

So, having read all this, now go ahead and watch the video and refer back to what I said above about adapting his tutorial to Drupal. 

PHP: Getting started with Composer Dependency Manager