How To Install Composer on Fedora 39
In this tutorial, we will show you how to install Composer on Fedora 39. Composer is a crucial tool for modern PHP development. It is a dependency manager that allows developers to manage and control packages that a PHP project requires. By automating the process of installing and updating project dependencies, Composer significantly simplifies the workflow for PHP developers.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the PHP Composer on a Fedora 39.
Prerequisites
Before diving into the installation process, let’s ensure that you have everything you need:
- A server running one of the following operating systems: Fedora 39.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- You will need access to the terminal to execute commands. Fedora 39 provides the Terminal application for this purpose. It can be found in your Applications menu.
- You’ll need an active internet connection to download Composer and its dependencies.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Composer on Fedora 39
Step 1. First, update the system packages to ensure that you have the latest versions. This can be done using the following command:
sudo dnf clean all sudo dnf update
Step 2. Installing Composer on Fedora 39.
Next, you need to download the Composer installer script using the curl
command. Run the following command in the terminal:
curl -sS https://getcomposer.org/installer -o composer-setup.php
To ensure script integrity, use the hash published on the Composer website:
HASH="$(curl -sS https://composer.github.io/installer.sig)" php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Now, you can install Composer using the installer script. Run the following command in the terminal:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
To verify that Composer has been installed successfully, you can run the following command in the terminal:
composer --version
With Composer downloaded, let’s configure it to be globally accessible. Move the Composer executable to a system-wide directory and add it to the system path:
sudo mv composer /usr/local/bin/composer export PATH=$PATH:$HOME/.composer/vendor/bin source ~/.bashrc
Step 3. Utilizing Composer in PHP Projects.
Composer simplifies project initialization, dependency management, and installation. Navigate to your project directory and execute:
composer init
Follow the interactive prompts to create your composer.json
file. Once completed, install project dependencies:
composer install
Composer intelligently fetches and installs the specified dependencies, optimizing your development workflow.
Congratulations! You have successfully installed Composer. Thanks for using this tutorial for installing the PHP Composer on your Fedora 39 system. For additional or useful information, we recommend you check the official Composer website.