Linux - How to Install PHP Composer on CentOS 8

  • Last update: Apr 3, 2024
  • Views: 46
  • Author: Admin
Linux - How to Install PHP Composer on CentOS 8

Colleagues hello to all.

In today's short article, I'll show you how to install PHP composer on Linux. Composer itself is a  dependency manager with which you can install additional packages that you need in your project.

 

Article content:

  1. Installing composer.

 

1. Installing composer.

 

1.1. Install required PHP packages and all other dependencies:

$. sudo yum install php-cli php-zip php-json wget unzip

linux_install_composer

 

1.2. After installing PHP, the next step download the Composer installer script itself:

$. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

linux_install_composer

 

1.3. Checking data integrity by comparing the SHA-384 hash of the file with the hash of the key of Composer itself.

$. HASH="$(wget -q -O - https://composer.github.io/installer.sig)"

linux_install_composer

 

1.4. Make sure the installation script is intact. If the hashes match, then the message will be shown: Installer verified

$. php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH& #39;) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

linux_install_composer

 

1.5. Install Composer.

$. sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

linux_install_composer

 

1.6. Check.

$. composer

linux_install_composer


 

Thank you all, I hope that my article helped you in some way.

SIMILAR ARTICLES