What is Composer? How to Install Laravel Using Composer?

Hasnain Abid Khanzada
Nov 2 · 4 min read

Most of you already heard a term Composer but only a few of you know how to exactly use it. Well, don’t worry as this article going to answer all your questions regarding the composer. Moreover, you will also see the practical example on how to use composer to install Laravel.

Before understanding about composer we have to first know about what is Dependency management.

Dependency management simply means managing the dependencies on which the project depends.

Suppose you are working with a project and you need a library to manipulate the project images in some way i.e creating/editing/adding watermarks etc. To achieve this task we can use the PHP library named Intervention. We have to download the library and manually add the library code with the right paths.

For small size projects adding libraries manually is not a huge task, but if you have complex projects then manually installing libraries in this way is not the right choice. Moreover, if you are working with PHP frameworks like Laravel then you should know that Laravel uses different libraries for different purposes. Because of a lot of dependencies on which Laravel depends, Recommend way of installing Laravel is through Composer

Composer is a dependency management software responsible for managing PHP project dependencies on the fly.

Before using the composer in any project, it is required to install it first on your computer.

Here are the steps:

1-First download the composer

2-Now open the executable file to install it

3-Make sure to check developer mode. This action will install the composer globally and you don’t have to add the composer path in an environment variable to use it.

4-Now you have to choose the command line PHP executable file.

5- If you are using xammp then click browse then navigate to the root path of your xammp installation and open the PHP folder where you will find an executable file named php.exe, Select it and click next

6- Now click next without checking proxy server as generally it is not needed (unless you are using some sort of VPN)

7-Now click finish and you are done with the installation of the composer.

Installing Laravel Using Composer

1-Installing any package with a composer is just a game of one line, enter one command in command prompt hit enter and from here composer will do the rest of the magic.

2-First download the Laravel installer using Composer:
composer global require Laravel/installer

3- This command will install the Laravel package globally in our local system

3-Now to create a project for Laravel, we can just run following command: Laravel new project-name

4-The above command will create a fresh Laravel directory in the specified folder

As you know Laravel has many dependencies but since we are using the composer to install Laravel, all the required dependencies will be automatically installed by the composer.

This was the just glimpse of how powerful Composer is. I recommend you to use it in your projects when installing any external library as it will be a life savior for you.

Let me know in the comments if you have any questions/issues regarding the composer. Thanks.


Originally published at https://www.codewithconcepts.com.

Hasnain Abid Khanzada

Written by

Passionate web developer who enjoying writing code but not without concepts.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade