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 How to set timezone dynamically and globally in Laravel

How to set timezone dynamically and globally in Laravel ?

September 20, 2022March 16, 2024

Laravel stores timezone configurations in config/app.php file and we can easily set timezone dynamically and globally in Laravel. Laravel usage carbon library to get the current date time and format, carbon also respects the timezone defined in config/app.php file. After php 5, php also introduced DateTime class to conduct the…

Read More
Php Laravel hasMany

How to Use hasMany Relationship in Laravel with Example ?

February 27, 2022November 10, 2023

Laravel hasMany relationship is used to create the relation between two tables. hasMany means create the relation one to Many. For example if a article have comments and we wanted to get all comments of the article then we can use hasMany relationship . Database Relations are used to create…

Read More
Php How to create multiple size thumbs from image in laravel

How to create multiple size thumbs from image in laravel 9 ?

May 14, 2022February 22, 2024

Resizing images can be a best performance booster for any application since this will load the proper size images. In this article i will show you to create multiple size thumbs from image in laravel using intervention package. Big size of image can reduce the performance of the application therefor…

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