Hello,
In this week’s feature highlight, we look at How to Composer on Rocky Linux 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
Install PHP by running the following command.
dnf install @php
Output:
[root@server ~]# dnf install @php
Last metadata expiration check: 0:50:18 ago on Thu 13 May 2021 01:00:13 PM EDT.
Dependencies resolved.
================================================================================
Package Arch Version Repo Size
================================================================================
Installing group/module packages:
php-cli x86_64 7.2.24-1.module+el8.3.0+200+280400f1 appstream 3.1 M
php-common x86_64 7.2.24-1.module+el8.3.0+200+280400f1 appstream 660 k
php-fpm x86_64 7.2.24-1.module+el8.3.0+200+280400f1 appstream 1.6 M
php-json x86_64 7.2.24-1.module+el8.3.0+200+280400f1 appstream 72 k
php-mbstring x86_64 7.2.24-1.module+el8.3.0+200+280400f1 appstream 579 k
php-xml x86_64 7.2.24-1.module+el8.3.0+200+280400f1 appstream 187 k
Download Composer installer
We will install wget package so we can download files over the internet, you can skip this part if you already have it installed.
dnf -y install wget
We will now download the composer from the official website
wget https://getcomposer.org/installer -O composer-installer.php
Output:
[root@vps ~]# wget https://getcomposer.org/installer -O composer-installer.php
--2021-02-23 12:59:23-- https://getcomposer.org/installer
Resolving getcomposer.org (getcomposer.org)... 142.44.245.229, 2607:5300:201:2100::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
2021-02-23 12:59:24 (420 KB/s) - ‘composer-installer.php’ saved [58460/58460]
Installing PHP Composer
Install the PHP Composer by running the following command.
php composer-installer.php --filename=composer --install-dir=/usr/local/bin
Output:
[root@server ~]# wget https://getcomposer.org/installer -O composer-installer.php
--2021-05-13 13:52:13-- https://getcomposer.org/installer
Resolving getcomposer.org (getcomposer.org)... 142.44.245.229, 2607:5300:201:2100::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
2021-05-13 13:52:14 (421 KB/s) - ‘composer-installer.php’ saved [58460/58460]
Verify the PHP Composer version once installation is done
composer --version
Output:
[root@server ~]# php composer-installer.php --filename=composer --install-dir=/usr/local/bin
All settings correct for using Composer
Downloading...
Composer (version 2.0.13) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Testing Composer
To test your installation, run the following command.
composer
Output:
[root@server ~]# composer --version
Composer version 2.0.13 2021-04-27 13:11:08
[root@server ~]# composer
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 2.0.13 2021-04-27 13:11:08
Usage:
command [options] [arguments]
Done!