How to Install Composer on CentOS Stream 9

Composer is a command line based program used to manage dependencies in PHP projects.

To install Composer, first move into your /usr/local/bin directory.

cd /usr/local/bin

Once in /usr/local/bin, run the following command

curl -sS http://getcomposer.org/installer | php

Rename composer.phar

mv composer.phar composer

.phar is short for PHP Archive

Run the following command to invoke composer

composer

Now, you should see the output instructions of composer

You should be able to run composer from any directory

To start using Composer in your project, all you need is a composer.json file  

Composer.json is a configuration file used in PHP projects that utilize the Composer dependency manager

Composer.json goes in the root of each project folder, as each project will have its own set of dependencies. Composer.json tells composer what to download.

For more information:

http://getcomposer.org

Previous article
Next article

Learn

Related articles

Getting Started with React

In this guide, we will cover the basics of setting up a local development environment, starting a simple React project, and the basics of how it works.

How to Create Bash Aliases

This tutorial demonstrates how to use the alias command to create personalized shortcuts, which can help you save time and feel less frustrated.

Using Git for PHP Development

This guide walks through the fundamentals of Git. In this tutorial, we will show you Git commands. For Linux you can use the built-in terminal.

How to Connect to MySQL with Laravel

In this guide, you will learn how to connect your Laravel application to your MySQL database.

How do you change the default SSH Port on CentOS Stream 9?

Changing the default SSH port adds an extra layer of security by reducing the risk of your password being cracked from a brute force attack.

What is Inheritance in PHP?

In this tutorial we will explain inheritance in PHP, a mechanism that allows a child class to inherit properties and behaviors from a parent class.