Composer: Remove or uninstall PHP packages

php
composer
packages
Nabil Hassen
Nabil Hassen
Nov 3, 2025
How to remove or uninstall PHP packages using Composer
Last updated on Nov 3, 2025
Table of contents:

How to remove or uninstall PHP packages using Composer

When managing PHP dependencies, it’s essential to know not only how to install but also how to properly remove or uninstall packages. Composer provides a simple and safe way to do this while keeping your project clean and dependency-free of unused packages. This guide explains exactly how to remove packages, update dependencies, and verify changes clearly, correctly, and efficiently.

Remove a PHP Package Using Composer

Before removing anything, identify the package you want to uninstall to confirm that the package exists in your project before proceeding.

Run:

composer show

You can also search for a specific package:

composer show vendor/package-name

To remove or uninstall a package, use the remove command:

composer remove vendor/package-name

What this does:

  • Uninstalls the specified package from the vendor/ directory.
  • Removes it from your composer.json and composer.lock files.
  • Automatically updates the autoloader to reflect the change.

Example:

composer remove guzzlehttp/guzzle

Composer will update your dependency tree and display a summary of the removed package and any other dependencies that are no longer needed.

Removing Multiple PHP Packages at Once using Composer

You can remove more than one package in a single command:

composer remove vendor/package-one vendor/package-two

Composer will uninstall both packages and clean up dependencies that are no longer used by your project.

Removing a Development-Only PHP Package

If the package was installed as a development dependency (with the --dev flag), you can remove it in the same way:

composer remove --dev vendor/package-name

This removes the package from the require-dev section of your composer.json.

Remove Manually by Editing composer.json (Not Recommended)

While you can manually delete a package entry from composer.json, it’s not recommended because:

  • It won’t automatically update composer.lock.
  • It won’t clean up the vendor/ directory.
  • It can lead to inconsistent states.

If you do manually edit composer.json, always run:

composer update

afterward to synchronize and reinstall only the required packages.

Verify the Removal

After the removal process, confirm that the package is no longer listed in your dependencies:

composer show

You should also check your composer.json file to ensure that the package has been deleted from either the require or require-dev section.

Common Mistakes to Avoid

  • Forgetting to run composer update or composer install after manual edits. Always sync your dependency files after editing.

  • Removing a package that’s required by another dependency. Composer will warn you and block removal if the package is still in use elsewhere.

  • Skipping autoload updates. If autoload references remain, run:

    composer dump-autoload

Always prefer using Composer’s built-in remove command instead of manual deletions. It ensures all references, autoloading, and dependency chains are properly updated keeping your PHP project stable, consistent, and lightweight.

Nabil Hassen
Nabil Hassen
Full Stack Web Developer

Stay Updated.

I'll you email you as soon as new, fresh content is published.

Thanks for subscribing to my blog.

Latest Posts