How to Install and Use PHP Composer on Ubuntu 18.04
The PHP Composer is a package management tool for PHP that is analogous to Nodejs' NPM and Ruby's bundle. We may declare needed libraries for our project and install them with a single command using the composer tool. We don't have to look for each library we want to install.
Installing and configuring PHP composer on Ubuntu 19.10, Ubuntu 18.04 LTS, and Ubuntu 16.04 LTS computers are covered in this article.
1. Requirements
With sudo privileges, shell access to a running Ubuntu machine.
PHP version 5.3 or above must be installed and configured.
2. On Ubuntu, install Composer.
On an Ubuntu machine, install PHP composer. All we have to do now is download the composer executable and place it in the bin folder.
-sS curl | php | https://getcomposer.org/installer
Now run the following instructions to make composer accessible to all users on your system, so that it may be used by all PHP applications.
chmod +x /usr/local/bin/composer sudo mv composer.phar /usr/local/bin/composer
After you've installed the composer on your computer. At the command prompt, type composer. This will provide you with information about the composer version as well as the choices accessible with the composer command.
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
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
--no-cache Prevent use of the cache
3. Composer should be upgraded.
By using the same instructions as for installation, you may get the newest version of the composer. The composer is also capable of updating itself. To update the composer itself, use the command below.
self-update sudo composer
Conclusion
This guide will show you how to install PHP Composer on Ubuntu. There are other commands that may be used to upgrade composers with a single command.