October 27, 2020
install-composer-on-centos-7

How to Install PHP Composer on CentOS 7

Introduction

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

Dependency management

Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with “packages” or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default, it does not install anything globally. Thus, it is a dependency manager. It does however support a “global” project for convenience via the global command.

This idea is not new and Composer is strongly inspired by node’s npm and ruby’s bundler.

Suppose:

  1. You have a project that depends on a number of libraries.
  2. Some of those libraries depend on other libraries.

Composer:

  1. Enables you to declare the libraries you depend on.
  2. Finds out which versions of which packages can and need to be installed, and installs them (meaning it downloads them into your project).
  3. You can update all your dependencies in one command.

See the Basic usage chapter for more details on declaring dependencies.

System Requirements

Composer requires PHP 5.3.2+ to run. A few sensitive php settings and compile flags are also required, but when using the installer you will be warned about any incompatibilities.

To install packages from sources instead of simple zip archives, you will need git, svn, fossil or hg depending on how the package is version-controlled.

Composer is multi-platform and we strive to make it run equally well on Windows, Linux and macOS.

Source website: https://getcomposer.org/doc/00-intro.md

Before installing Composer you should have the following prerequsitis:

  1. Sudo privileged of your server.
  2. PHP must be installed on your server.

Now lets start with the installation process:

Install Composer on CentOS

To install composer we need to download composer executable and put into the /bin directory.

curl -sS https://getcomposer.org/installer | php

To make composer use globally for all user in your server we will use command as follows:-

mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer

To find the version of your composer user the command as follows:

[[email protected] ~]# composer -V

Composer version 1.10.8 2020-06-24 21:23:30

Update Composer

In order to update the composer just use the command as follows:

composer self-update

Now you have successfully installed composer on your server 🙂

Vedant Singh

Linux System Administrator | Entrepreneur | Founder Techmion. I have started my career as a Linux system Administrator after that quit my job to start something new that excites me and started a Tech Company in order to provide the best technology to my clients. My Company website link: https://www.techmion.com/ For Bulk, SMS-Marketing follows the link : https://www.pingsms.in/

View all posts by Vedant Singh →

Leave a Reply

Your email address will not be published. Required fields are marked *