Search⌘ K

How to Use Packagist and Composer

Explore the use of Packagist and Composer to manage PHP code libraries efficiently. Learn how to install Composer, search and add packages from Packagist, handle dependencies automatically, update packages, and remove them as needed. This lesson helps you integrate external libraries seamlessly into your PHP projects to save development time.

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
...