Composer is a dependency manager for PHP, it like npm for Node.js or pip to Python. So, it allows you to declare the libraries your project depends on and it will manage (installing/updating) them for you. It is used in all modern PHP frameworks and platforms such as Laravel, Symfony, Drupal, and Magento 2.
This article explains how to install PHP Composer on Centos 8. By downloading the latest release of PHP Composer from their official website.
Installing dependencies packages
However, before starting you have to install some dependencies of Composer like PHP.
01- So, open a terminal and run the following command:
$ sudo dnf install php php-cli php-json php-zip curl unzip
02- Check the version of PHP by executing the below command:
$ php -version
PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Install PHP Composer Centos 8
01- let’s use the curl
command to download the latest PHP Composer version
$ curl -sS https://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 1.10.13) successfully installed to: //composer.phar Use it: php composer.phar
02- To make PHP Composer globally available, move it to the binary folder /usr/local/bin
as below:
$ sudo mv composer.phar /usr/local/bin/composer $ sudo chmod +x /usr/local/bin/composer $ source ~/.bashrc
03- Finally, to check if you installed accurately PHP Composer, use the below command check the version:
$ composer -v
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.10.13 2020-09-09 11:46:34
Conclusion
You have successfully learned how to install PHP Composer on Centos 8. You can now visit the official PHP Composer Documentation page and learn how to get started by creating PHP Projects.
You might want to check the following guides: