How to Use Packagist and Composer

Learn how to use Packagist and Composer to integrate existing code libraries into PHP applications.

In this lesson, we’ll learn where the PHP community stores all the code libraries that are written worldwide. Have you ever wondered where to get a code library to manage website users or to handle shopping carts? Would you rather write less code and still achieve more?

If you’re a PHP programmer and answered yes to at least one of these questions, you should familiarize yourself with Packagist and Composer. They allow us to easily find PHP libraries, download them to our website, and manage them.

Packagist is a huge repository of PHP code libraries and Composer is a dependency manager, which allows us to download the code libraries from Packagist straight to our project along with all of their dependencies (the code packages on which they are dependent).

How to install Composer

Installing Composer on Linux and Mac is done via the command-line:

$ curl -s https://getcomposer.org/installer | php

We can examine the installation by typing the following command into the command-line:

$  php composer.phar

If Composer is properly installed, we’ll see all the Composer commands with a short description of what they do. This is already set up on the Educative platform for your convenience.

Get hands-on with 1200+ tech skills courses.