Linux Commands and Scripts

How To Install Composer PHP Dependency On CentOS 7

In this article, we will learn how to install Composer PHP dependency manager CentOS 7.

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.

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.

To install Composer, we need to follow some simple steps.

1. Keep the server up-to-date

# yum -y update

2. Change working directory

# cd /usr/local/src

3. Now, install Composer by using cURL

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

We have successfully install Composer.

To use Composer globally composer.phar to /usr/local/bin/ using following command.

# mv -f composer.phar /usr/local/bin/composer

Verify the Composer is working using following command:

# composer -V

If you want to run Composer via different PHP version, use PHP bin path with Composer path. As shown below:

# /usr/local/bin/php /usr/local/bin/composer command

All selectors php bin path can be found in /opt/alt

# /opt/alt/php73/usr/bin/php /usr/local/bin/composer command

We have seen how to install composer PHP dependency manager CentOS 7.

[Need assistance to fix this error or install tools? We’ll help you.]

Related Articles