Composer is the standard dependency manager for PHP. If you're setting up Laravel, Symfony, or really any modern PHP project, this is one of the first tools you'll install. This guide covers installing it on Pop!_OS or any Ubuntu-based distribution, with the official hash-verification step so you're not just trusting a random script.
Prerequisites
You'll need:
A Pop!_OS or Ubuntu system with terminal (sudo) access
gitandcurlinstalled
Check whether you already have them:
git -v && curl -VIf either is missing:
sudo apt-get install git curlStep 1 — Install PHP CLI and Required Extensions
Composer needs php-cli to run, and unzip to extract package archives.
sudo apt update
sudo apt install php-cli unzipConfirm the installation with Y when prompted.
Step 2 — Download the Composer Installer
Composer installs itself using a small PHP script. Download it to a temporary location:
cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.phpStep 3 — Verify the Installer
Mak sure you don't skip this as it confirms the script you downloaded hasn't been tampered with. Composer publishes the expected hash at getcomposer.org/download; fetch it programmatically and compare:
HASH=$(curl -sS https://composer.github.io/installer.sig)
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified' . PHP_EOL; } else { echo 'Installer corrupt' . PHP_EOL; unlink('/tmp/composer-setup.php'); }"You should see:
Installer verifiedIf you see Installer corrupt instead, delete the file and re-download it. Don't proceed with a script that fails verification.
Step 4 — Install Composer Globally
This installs Composer as a system-wide composer command:
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composerYou should see output confirming the install, ending with something like:
Composer (version 2.x.x) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composerStep 5 — Verify the Installation
composer --versionYou'll see Composer's ASCII logo and its version number printed. This confirms Composer is installed and available from anywhere on your system.
Step 6 — Clean Up
Remove the temporary installer script now that it's no longer needed:
rm /tmp/composer-setup.phpCommon Issues
composer: command not found: Check that /usr/local/bin is in your PATH: echo $PATH. If it's missing, add export PATH="/usr/local/bin:$PATH" to your ~/.bashrc and reload with source ~/.bashrc.
Permission errors during install: Make sure you're running Step 4 with sudo, since it writes to /usr/local/bin, a system directory.
Wrong PHP version picked up: If you have multiple PHP versions installed, php-cli might not point at the one you expect. Run php -v to check, and use update-alternatives --config php to switch if needed.
What's Next
With Composer installed, you're ready to scaffold a new project:
composer create-project laravel/laravel my-appOr add Composer as a dependency manager to an existing PHP project by running composer init in its root directory.