Getting Started With Composer In PHP

Prem Tiwari - - PHP Tutorial

Composer is a tool that allows to manage your third party dependencies in your PHP application, it will allow you to create a list of all third party scripts and libraries and their version number. Composer will then look into the repository of the third party library and the current version number and will automatically download the library into your application


Installing Composer

Composer is bundled as an executable Phar archive, so make sure you have the Phar extension enabled in your php.ini file (uncomment

I recommend download the latest snapshot of the Composer executable directly from the project’s website.

Download Composer into this folder with the following command :

You should see a success message that looks something like this:

Ultimately as a user, all you have to do is drop a composer.json file in your project and run composer.phar install. This composer.json file defines your project dependencies, and optionally configures composer (more on that later). Here is a minimal example to require one library:

You can declare it here (see the last two lines below) and Composer will generate an autoloader for the user that can load all of his project dependencies.

Make sure you also check out the official Composer documentation for updates and techniques I couldn’t discuss in this article.

Prem Tiwari

Prem Tiwari is the founder of and also a professional developer and a blogger by hobby.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.