Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install Composer on CentOS 8 - DesignLinux

May 29 2020
designlinux 0 Comments

Composer is the most popular package management program for PHP, that offers a standard form for managing dependencies of PHP applications and needed libraries that your project relies on and it will manage (install/update) them for you easily.

Composer is a command-line program that installs dependencies and libraries for applications that are available on packagist.org, which is its main repository consist of available packages.

Composer is a very helpful tool for developers when they are in need and want to manage and incorporate the packages for their PHP project. It speeds up time and is recommended to solve any crucial issues in most of the web projects.

In this tutorial, we will show you how to install Composer on CentOS 8 Linux.

Requirements

  • A root account or sudo privileged account with shell access.
  • PHP 5.3.2+ with needed extensions and settings.

Installing Composer on CentOS 8

To install Composer, you must install PHP on the system with required PHP extensions using the following dnf command.

# dnf install php php-cli php-zip php-json
Install PHP on CentOS 8

Install PHP on CentOS 8

Now install Composer using an installer that you can execute locally as part of your project, or globally as a system-wide executable.

Install Composer Locally

To install Composer locally on your current directory, execute the following script in your terminal.

# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
# php -r "if (hash_file('sha384', 'composer-setup.php') === 'c5b9b6d368201a9db6f74e2611495f369991b72d9c8cbd3ffbc63edff210eb73d46ffbfce88669ad33695ef77dc76976') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
# php composer-setup.php
# php -r "unlink('composer-setup.php');"
Install Composer Locally in CentOS 8

Install Composer Locally in CentOS 8

The above installer will check some php.ini settings and alert you if they are set wrongly. Then the installer will download the latest composer.phar in the current working directory.

The 4 lines above will, in order:

  • Download the installer to the current directory.
  • Verify the installer signature (SHA-384).
  • Run the installer.
  • Remove the installer.

Finally, run php composer.phar in order to run Composer.

# php composer.phar
Run PHP Composer in CentOS 8

Run PHP Composer in CentOS 8

Install Composer Globally

To install and access Composer globally system-wide, you need to place Composer PHAR in your system PATH, so that you can execute it without using the PHP interpreter.

To install Composer globally for all users, run the installer using the following commands.

# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
# php -r "if (hash_file('sha384', 'composer-setup.php') === 'c5b9b6d368201a9db6f74e2611495f369991b72d9c8cbd3ffbc63edff210eb73d46ffbfce88669ad33695ef77dc76976') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
# php composer-setup.php
# php -r "unlink('composer-setup.php');"
# mv composer.phar /usr/local/bin/composer
# chmod +x /usr/local/bin/composer
# composer -V
Install Composer Globally in CentOS 8

Install Composer Globally in CentOS 8

Now that you’ve installed Composer successfully on your CentOS 8 system. To learn more about the PHP Composer and how can you utilize it in your projects visit the official documentation.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit

Related

Tags: CentOS Tips, PHP Tips

Pentoo – A Security-Focused Linux Distro Based on Gentoo

Prev Post

How to Install VirtualBox on Ubuntu 20.04

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 259
  • 614,631

DesignLinux.com © All rights reserved

Go to mobile version