Use PHP Composer on CentOS Computers

This section provides a tutorial example on how to install PHP Composer to manage PHP packages on CentOS systems.

What is PHP Composer? PHP Composer is an extension package manager for the PHP environment. Composer will pull in all the required extension packages your PHP script depends on and manage them for you.

Here is what I did to install PHP Composer on my CentOS 8 computer.

1. Install required tools:

herong$ sudo dnf install php-cli php-zip wget unzip

2. Download the Composer setup script:

herong$ sudo php -r \
  "copy('', 'composer-setup.php');"

3. Run Composer setup script:

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

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

4. Try Composer command:

herong$ /usr/local/bin/composer
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 2.1.3 2021-06-09 16:31:20

  command [options] [arguments]

Available commands:
  about     Shows a short information about Composer.
  archive   Creates an archive of this composer package.
  config    Sets config options.
  exec      Executes a vendored binary/script.
  help      Displays help for a command
  info      Shows information about packages.
  list      Lists commands
  require   Adds required packages to your composer.json and installs them.

5. Run "composer show --platform" command to show all PHP packages on the platform.

herong$ sudo /usr/local/bin/composer show --platform
composer-plugin-api    2.1.0      The Composer Plugin API
composer-runtime-api   2.1.0      The Composer Runtime API
ext-calendar           7.2.24     The calendar PHP extension
ext-ctype              7.2.24     The ctype PHP extension
ext-curl               7.2.24     The curl PHP extension
ext-date               7.2.24     The date PHP extension
ext-dom                20031129   The dom PHP extension
ext-exif               7.2.24     The exif PHP extension
ext-fileinfo           1.0.5      The fileinfo PHP extension
ext-filter             7.2.24     The filter PHP extension
ext-ftp                7.2.24     The ftp PHP extension
ext-gettext            7.2.24     The gettext PHP extension
ext-hash               1.0        The hash PHP extension
ext-iconv              7.2.24     The iconv PHP extension
ext-json               1.6.0      The json PHP extension
ext-libxml             7.2.24     The libxml PHP extension
ext-mbstring           7.2.24     The mbstring PHP extension
ext-mysqli             7.2.24     The mysqli PHP extension
lib-bz2                1.0.6      The bz2 library
lib-curl               7.61.1     The curl library
lib-curl-libssh        0.9.4      curl libssh version
lib-curl-openssl    curl OpenSSL version (
lib-curl-zlib          1.2.11     curl zlib version
lib-date-timelib       2017.09    date timelib version
lib-date-zoneinfo      0          zoneinfo ("Olson") database for date
lib-fileinfo-libmagic  531        fileinfo libmagic version
lib-iconv              2.28       The iconv library
lib-libxml             2.9.7      libxml library version
lib-libxslt            1.1.32     The libxslt library
php                    7.2.24     The PHP interpreter
php-64bit              7.2.24     The PHP interpreter, 64bit
php-ipv6               7.2.24     The PHP interpreter, with IPv6 support

Table of Contents

 About This Book

 Introduction and Installation of PHP

 PHP Script File Syntax

 PHP Data Types and Data Literals

 Variables, References, and Constants

 Expressions, Operations and Type Conversions

 Conditional Statements - "if" and "switch"

 Loop Statements - "while", "for", and "do ... while"

 Function Declaration, Arguments, and Return Values

 Arrays - Ordered Maps

 Interface with Operating System

 Introduction of Class and Object

 Integrating PHP with Apache Web Server

 Retrieving Information from HTTP Requests

 Creating and Managing Sessions in PHP Scripts

 Sending and Receiving Cookies in PHP Scripts

 Controlling HTTP Response Header Lines in PHP Scripts

 Managing File Upload

 MySQL Server Connection and Access Functions

 Functions to Manage Directories, Files and Images

 SOAP Extension Function and Calling Web Services

 SOAP Server Functions and Examples

 Localization Overview of Web Applications

 Using Non-ASCII Characters in HTML Documents

 Using Non-ASCII Characters as PHP Script String Literals

 Receiving Non-ASCII Characters from Input Forms

 "mbstring" Extension and Non-ASCII Encoding Management

 Managing Non-ASCII Character Strings with MySQL Servers

 Parsing and Managing HTML Documents

 Configuring and Sending Out Emails

 Image and Picture Processing

 Managing ZIP Archive Files

 Managing PHP Engine and Modules on macOS

Managing PHP Engine and Modules on CentOS

 PHP Version Pre-Installed on CentOS

 Install PHP Extensions on CentOS

 PHP Version Pre-Installed on CentOS 6

Use PHP Composer on CentOS Computers

 Archived Tutorials


 Full Version in PDF/EPUB