DEV Community

Ankit Verma
Ankit Verma

Posted on

How can I remove a package from Laravel using PHP Composer?

When working with Laravel, you may need to remove a package that is no longer required. PHP Composer makes it easy to uninstall packages cleanly from your project. In this blog, we’ll go over the simple steps to remove a package from Laravel using Composer.

Steps to Remove a Package

1. Find the Installed Package

Before removing a package, you might want to check the installed packages in your Laravel project. You can do this by running:

composer show
Enter fullscreen mode Exit fullscreen mode

This command lists all installed packages, helping you confirm the exact name of the package you want to remove.

2. Remove the Package Using Composer

To uninstall a package, use the following command:

composer remove vendor/package-name
Enter fullscreen mode Exit fullscreen mode

For example, if you want to remove laravel/telescope, you would run:

composer remove laravel/telescope
Enter fullscreen mode Exit fullscreen mode

3. Clear Configuration and Cache (Optional)

After removing a package, it’s a good practice to clear Laravel’s cache and configurations to avoid issues:

php artisan cache:clear
php artisan config:clear
Enter fullscreen mode Exit fullscreen mode

4. Remove Unused Dependencies (Optional)

To clean up any unnecessary dependencies that may no longer be needed, run:

composer autoremove
Enter fullscreen mode Exit fullscreen mode

5. Verify Removal

Check your composer.json file to ensure the package has been removed. Additionally, run:

composer dump-autoload
Enter fullscreen mode Exit fullscreen mode

This regenerates the Composer autoload files, ensuring Laravel runs smoothly.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more