How to install Composer on Ubuntu 22.04?
Overview
Composer is a tool frequently used for managing dependencies in PHP. Its main purpose is to simplify the installation and updating process of project dependencies. Composer identifies the packages that a project relies on and installs them, utilizing the versions that are compatible with the project's specifications. It is also a popular choice for creating new projects based on well-known PHP frameworks.
Prerequisites
There are certain prerequisites that need to be met before you begin.
Ubuntu 22.04 LTS configured on your system.
Non-root sudo user privileges.
Get Started
Step 1: Configuring PHP and other dependencies
Update the package index:
Proceed with installing the necessary prerequisites, such as php-cli:
Step 2: Installing Composer
Ensure that you are in the home directory and then use curl to obtain the Composer installer:
Use the 'curl' command to retrieve the latest signature and save it in a shell variable:
Confirm the acquired value by executing the following command:
Visit the Composer Public Keys / Signatures page and confirm that the installer matches to the SHA-384 hash of the most recent installer.
Ensure that the installation script is secure by running the PHP code provided on the Composer download page.
Note: To proceed, you must ensure that the installation script is not corrupted and that you have used the correct hash. If you encounter an 'Installer corrupt' error message, re-download the installation script and verify it again. Only after obtaining an 'Installer Verified' message should you proceed further.
To set up Composer globally, execute the command below. This will fetch and install Composer as a command that can be accessed from anywhere in the system, and it will be called "composer", located in the /usr/local/bin directory.
Verify your installation:
Conclusion
This confirms that Composer has been installed on your system successfully and is accessible throughout the system.
Last updated