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

Laravel How to Run Cron Job Scheduler in laravel

How to Run Cron Job Scheduler in laravel ?

May 18, 2022May 26, 2022

Cron are used to schedule a service or task run periodically on specific time, date or intervals. In laravel we can Run Cron Job Scheduler same in the way we use to run in Unix system by adding the cron in crontab configuration but in laravel there is a standard…

Read More
Php How to Add Default Value to Column in Laravel Migration

How to Add Default Value to Column in Laravel Migration?

August 17, 2022March 16, 2024

Default value to column is useful when we want to auto fill the default defined value of column during insertion of other values of table So In our this article i will show you to add default value to column in laravel migration. We can add any type of data…

Read More
Php How to convert html to pdf in laravel 8 9

How to convert html to pdf in laravel 8 / 9?

May 5, 2022November 6, 2023

Dompdf package has rich features to convert html to PDF in laravel. In this article we will learn to use html to PDF using dompdf package. In most of the website there is need of to convert html to PDF or export the data in PDF format, Dompdf does this…

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

  • 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 Resilience of Nature: How Forests Recover After Fires
  • Understanding Laravel Cookie Consent for GDPR Compliance
  • Understanding High Vulnerabilities: A Critical Overview of the Week of May 12, 2025
  • Installing a LAMP Stack on Ubuntu: A Comprehensive Guide
  • Understanding High Vulnerabilities: A Deep Dive into Recent Security Concerns
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version