Installing Composer

A complete guide to getting Composer up and running on your server.

Composer is the de facto dependency manager for PHP. It takes the pain out of managing third-party libraries — whether you're working with Symfony, Laravel, PHPUnit, Guzzle, or any of the thousands of packages available on Packagist. If you're building a modern PHP application, Composer is non-negotiable.

Prerequisites

  1. Connect to your server via SSH (PuTTY on Windows, or your terminal on Linux/macOS).
  2. Make sure PHP is installed and up to date (version 7.2.5 or higher):
   php -v
  1. Install curl and git if they aren't already present:
   sudo apt update
   sudo apt install curl git -y   # Ubuntu/Debian
   # or
   sudo yum install curl git -y   # CentOS/Rocky/AlmaLinux

Installation

  1. Navigate to a directory on your system's PATH — /usr/local/bin is a solid choice:
   cd /usr/local/bin
  1. Download and run the Composer installer in one go:
   sudo curl -sS https://getcomposer.org/installer | php

If curl isn't cooperating, you can do this the manual way:

   sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
   sudo php composer-setup.php
   sudo rm composer-setup.php
  1. Rename the file and make it executable so you can call it from anywhere:
   sudo mv composer.phar composer
   sudo chmod +x composer

Getting started with a project

  1. Head to your project root:
   cd /var/www/my-project
  1. Scaffold a new composer.json by running the interactive initializer:
   composer init
  1. Install all declared dependencies:
   composer install
  1. Pull in a package — here's an example with the Guzzle HTTP client:
   composer require guzzlehttp/guzzle
  1. Upgrade everything to the latest compatible versions:
   composer update

Handy commands to know

What you want to do Command
List installed packages composer show
Update a single package composer update vendor/package
Remove a package composer remove vendor/package
Clear the cache composer clear-cache
Install without cache (great for debugging) composer install --no-cache

Help

If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!

Updated at:
Need help?Our engineers will help you free of charge with any question in minutesContact us