Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
Install Composer

What is composer and how to install composer?

Aman Jain, September 18, 2021September 21, 2021

Composer is a dependency manager tool for PHP. Using the composer we can manage the package dependency and version of the packages. Composer is different from npm (Node package manager) and apt-get because it only contain the dependency of project.

Composer creates a compose.json file to contain the information about the project and dependencies like packages, module etc. when we install the dependencies using the composer it creates a folder named as vendor and install dependencies there.

Let’s install the composer:

System Requirements

Composer requires PHP 5.3.2+ to run. Some additional seating are also required but composer will notify you when you use it.

Installation of composer in ubuntu and macOS   

Before start make sure you have enabled the PHP CLI, so check php versions first in command line.

php -v 

it should output like below:

PHP 7.3.1 (cli) (built: Jul  5 2021 15:13:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.3.1, Copyright (c), by Zend Technologies

if it’s now showing as above then you need to install the php first, you can read How to Install php, apache, mysql(Lamp) and phpmysadmin on Ubuntu.

Now, There is two way to install the composer 

  1. Locally
  2. Globally

1. Installing Composer Locally in project

Go to the project location and open the terminal or First open the terminal and then go to path of project.

Type below command

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

above command will download composer-setup.php in current directory

php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Above Command will check the installer is not corrupted and verified.

php composer-setup.php

This will check the php.ini settings and warn you if its not correct. It will run above script to install the composer in directory.

php -r "unlink('composer-setup.php');"

delete the composer-setup file.

2. Installing Composer Globally

We already downloaded the composer.phar file in directory. If we want to use it globally then we need to move it into /usr/local/bin/ so it will be accessible globally.

sudo mv composer.phar /usr/local/bin/composer

There is few arguments which we can use

–install-dir

To install the composer in sepecific directory

Example:

php composer-setup.php --install-dir=bin

–filename

You can specify the filename (default: composer.phar) using the –filename option. Example:

php composer-setup.php --filename=composer

–version

Change the version of composer.

Example:

php composer-setup.php --version=1.0.0-alpha8

Screenshot 2021 09 18 at 9.47.23 AM
Composer version

Install composer in windows

As we installed the composer using the command line in the same way we can install in windows but in windows we have more simple way to install it using window executable installer.

Download and run Composer-Setup.exe. It will install the latest Composer version and set up your PATH so that you can call composer from any directory in your command line.

Related

Php

Post navigation

Previous post
Next post

Related Posts

Php Laravel Redirect from Http to Https Secure URL

Laravel Redirect from Http to Https Secure URL

August 26, 2022March 16, 2024

To redirect from http to https secure url in laravel we can achieve by multiple ways. While deploying application to server we need to make our website secure and robust so attackers can not attack easily on website. In this tutorial we will learn to redirect the http to https…

Read More
Php How to Show Human Readable Date in Ago Format in Laravel

How to Show Human Readable Date in Ago Format in Laravel ?

September 5, 2022March 16, 2024

In this article we will learn to show human readable date in ago format in laravel. Its best way to show the ago date on our application since its human readable and we don’t need to care about timezones because we can keep any timezone and it will always show…

Read More
Php file_get_contents Post and Get Request with Headers in Laravel

file_get_contents Post and Get Request with Headers in Laravel ?

June 13, 2022June 13, 2022

In this article i will show you to send file_get_contents post and get request with headers in laravel. As we know file_get_contents is php inbuilt core function used to access the local file and remote URLs. File_get_contents is used to read the file in different modes and to send the…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Transformative Power of Education in the Digital Age
  • Understanding High Vulnerabilities: A Closer Look at the Week of July 14, 2025
  • Exploring Fresh Resources for Web Designers and Developers
  • The Intersection of Security and Technology: Understanding Vulnerabilities
  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version