Uninstall PHP Composer on Debian
This guide explains how to completely remove Composer from your system. These instructions are specifically for systems where Composer was installed using the official installation method from getcomposer.org or my previous Composer installation guide on this site.
Before proceeding with the uninstallation, you might want to check your Composer version and installation path:
which composer
composer --version
The Linux distribution used was Debian 12 (Bookworm), but it should work on other Debian-based systems, like Ubuntu.
Uninstallation commands
For a quick uninstallation, use one of these commands depending on your installation type:
For local installation:
The Composer executable is typically located in the current directory named composer.phar
. To remove it, run:
rm composer.phar
For global installation:
sudo rm /usr/local/bin/composer
Complete removal process
To thoroughly remove Composer and all its associated files, follow these steps:
1. Find all Composer-related files
sudo find / -name composer 2>/dev/null
This command will typically show files in locations such as:
/usr/local/bin/composer
/home/username/.cache/composer
/home/username/.config/composer
/home/username/.local/share/composer
where username
is your actual username.
If you have files that require exclussion, you can use the grep
command to filter the results:
sudo find / -name composer 2>/dev/null | grep -v "/var/www"
This command will exclude any files located in the /var/www
directory.
You can adjust the path in the grep -v
command to exclude any other directories as needed using the same pattern (pipe |
to add more exclusions).
2. Remove all Composer files and directories
WARNING: Be absolutely certain about deleting these files before proceeding!
To remove all files at once:
sudo find / -name composer -exec rm -R {} -r \+;
Alternatively, you can remove files individually using:
sudo rm -rf /usr/local/bin/composer
sudo rm -rf ~/.cache/composer
sudo rm -rf ~/.config/composer
sudo rm -rf ~/.local/share/composer
3. Verify removal
After uninstallation, verify that Composer is no longer present:
composer --version
This command should return a "command not found" error if Composer was successfully removed.
Resources
- Linux Notepad: Install PHP Composer on Debian:
- Official Composer Documentation
- StackOverflow: Additional information about removing/uninstalling composer