How to install a Composer package from the command line

A tutorial for installing a Composer package from the command line.

 

Before we get started

  • Do you have Composer installed?
  • Do you have a valid composer.json file setup with correct file permissions?
  • Do you know how to open a terminal window and navigate to the directory of your composer.json file?

If you answered no to any of these questions, start with an introduction to Composer tutorial before attempting this one.

What you’ll need to install a Composer package

  • Package author or source
  • Package name
  • Version

 

Example commands for installing a Composer package

composer require johnpbloch/wordpress:4.7.2

composer require wpackagist-plugin/regenerate-thumbnails:2.2.6

 

Command Structure

Tell composer to install a package: composer require

Tell composer the source, package name, and version:  source/package:version

Putting it all together: composer require source/package:version

 

Still need help?

Talk to php developer at Digimix Web Development New York.