How to Install PHP Composer on CentOS 8
Composer is basically a dependency manager for the programming language, PHP. It functions as some sort of project manager that helps the programmer manage dependencies that will be used on a project to project basis.
Installing PHP
dnf install @php
Output:
[root@vps ~]# dnf install @php
Last metadata expiration check: 0:14:17 ago on Fri 25 Dec 2020 03:00:28 AM EST.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing group/module packages:
php-mbstring x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 580 k
php-xml x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 188 k
Installing dependencies:
libxslt x86_64 1.1.32-5.el8 BaseOS 250 k
Installing module profiles:
php/common
Transaction Summary
================================================================================
Install 3 Packages
Total download size: 1.0 M
Installed size: 2.8 M
Is this ok [y/N]: y
Download Composer installer
dnf -y install wget
Output:
[root@vps ~]# dnf -y install wget
Last metadata expiration check: 0:14:45 ago on Fri 25 Dec 2020 03:00:28 AM EST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
wget x86_64 1.19.5-10.el8 AppStream 734 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 734 k
Installed size: 2.8 M
To install Composer locally by running following command
wget https://getcomposer.org/installer -O composer-installer.php
Output:
[root@vps ~]# wget https://getcomposer.org/installer -O composer-installer.php
--2020-12-25 03:15:18-- https://getcomposer.org/installer
Resolving getcomposer.org (getcomposer.org)... 142.44.245.229, 2607:5300:201:210 0::4:d105
Connecting to getcomposer.org (getcomposer.org)|142.44.245.229|:443... connected .
HTTP request sent, awaiting response... 200 OK
Length: 58460 (57K) [application/octet-stream]
Saving to: ‘composer-installer.php’
composer-installer. 100%[===================>] 57.09K --.-KB/s in 0.1s
2020-12-25 03:15:19 (414 KB/s) - ‘composer-installer.php’ saved [58460/58460]
Installing PHP Composer
php composer-installer.php --filename=composer --install-dir=/usr/local/bin
Output:
[root@vps ~]# php composer-installer.php --filename=composer --install-dir= /usr/local/bin
All settings correct for using Composer
Downloading...
Composer (version 2.0.8) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Verify the PHP Composer version once installation is done
composer --version
Output:
[root@vps ~]# composer --version
Composer version 2.0.8 2020-12-03 17:20:38
Testing Composer
To test your installation, run the following command.
composer
Output:
[root@vps ~]# composer --version
Composer version 2.0.8 2020-12-03 17:20:38
[root@vps ~]# composer
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 2.0.8 2020-12-03 17:20:38
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS