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
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
For example, if you want to remove laravel/telescope
, you would run:
composer remove laravel/telescope
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
4. Remove Unused Dependencies (Optional)
To clean up any unnecessary dependencies that may no longer be needed, run:
composer autoremove
5. Verify Removal
Check your composer.json
file to ensure the package has been removed. Additionally, run:
composer dump-autoload
This regenerates the Composer autoload files, ensuring Laravel runs smoothly.