Set up PHP Composer on AlmaLinux 8

In this article, we want to teach you How To Set up a PHP Composer on AlmaLinux 8.

Composer is a dependency manager for PHP. The composer will manage the dependencies you require on a project-by-project basis.

This means that Composer will pull in all the required libraries, dependencies and manage them all in one place.

How To Set up PHP Composer on AlmaLinux 8

Before you start to install PHP Composer on AlmaLinux 8, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with AlmaLinux 8.

Now follow the steps below to set up PHP Composer on your server.

Install PHP on AlmaLinux 8

First, you need to update your local package index with the following command:

sudo dnf update -y

To install PHP on AlmaLinux 8, you need to install the Epel release repo with the command below:

sudo dnf install epel-release

Then, use the following command to install PHP on your server:

sudo dnf install @php

You can verify your PHP installation by checking its version:

php -v

In your output you will see:

Output
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Install Composer on AlmaLinux 8

At this point, you need to download the Composer installer script. To do this, first, install the wget tool with the command below:

sudo dnf install wget

Then, use the wget command to download the Composer:

wget https://getcomposer.org/installer -O composer-installer.php

When your download is completed, use the following command to install Composer on AlmaLinux 8:

php composer-installer.php --filename=composer --install-dir=/usr/local/bin

In your output you will see:

Output
All settings correct for using Composer
Downloading...
Composer (version 2.1.14) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

You can verify your PHP Composer installation by checking its version:

composer --version

In your output you will see:

Output
Composer version 2.1.14 2021-11-30 10:51:43

Also, you can test your Composer on AlmaLinux 8 by using the command below:

composer

You will get the following output:

Output
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.1.14 2021-11-30 10:51:43
Usage:
  command [options] [arguments]
Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
...

Conclusion

As a PHP developer, Composer will become your best friend, and as its usage increases, it will become an essential part of writing PHP on a day-to-day basis.

At this point, you learn to install PHP Composer on AlmaLinux 8.

Hope you enjoy it.

May this article about Install and Use Composer on Ubuntu 20.04 be useful for you.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!