Here is the step-by-step guide to remove a package from Laravel using Composer.
- Remove the package declaration from the composer.json file (in the “require” section).
- Use the “composer remove” command.
- Remove Service Provider from app/config/app.php file.
- Remove any Class Aliases from the app/config/app.php file.
- Run migrations (if necessary).
- Clear cached configurations.
- Check for remaining references.
Let’s go through step-by-step.
Step 1: Remove the package declaration from the composer.json file
Open the composer.json file located at the root of your Laravel project.
Locate the require section and find the package you want to remove.
Remove the line that references the package.
Step 2: Use the composer remove command
Go to your Laravel root and use this command:
composer remove vendor/package-name
Replace the vendor/package-name with the actual name of the package you want to remove.
Step 3: Remove the Service Provider from the app/config/app.php file
Open the config/app.php file.
Locate the providers array.
Delete the service provider related to the package.
Step 4: Remove any Class Aliases from the app/config/app.php file
Still, in the config/app.php file, locate the aliases array.
Delete any aliases related to the package.
Step 5: Run migrations (if necessary)
If the package added database tables or made other changes to your database, you might need to reverse these changes.
This can often be done by running:
php artisan migrate:rollback
Step 6: Clear cached configurations
It’s important to clear these caches to ensure the application doesn’t reference the removed package:
php artisan config:clear
Step 7: Check for remaining references
You must review your codebase for any lingering references to the removed package. This could be in controllers, views, middleware, routes, or other configuration files. Remove or adjust these references as necessary.
That’s it!

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.