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 slug generator using trait

Laravel reusable slug generator using trait

November 8, 2021November 8, 2021

In our last article Laravel slug generator with example we demonstrate how we can generate slug for model but in that article we need to rewrite the same code for multiple models if we want use the slug generation in multiple model. so in this article i will show you…

Read More
Php How to create seeders in laravel

How to create seeders in laravel 9 with example ?

February 19, 2022February 22, 2022

As the name implies seeders, seeder are used to fill the database using seed classes. Sometimes in our application we wanted to test our application with some data and in that case we require seed the database may be with dummy data. Using the seeder we can create n number…

Read More

What is Access Modifiers ?

July 18, 2021August 2, 2021

In object oriented programming(oops) to set the visibility of classes, variables and methods we are using access modifiers. So Access modifiers are used the encapsulation of class properties. There are three types of access modifiers in any language (Php, java or c etc. ) Private Protected Public 1. Private Access…

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