How to Remove Package from Laravel?

November 26, 2022
Laravel
How to Remove Package from Laravel?

In this tutorial, you will learn how to remove the package from laravel.

By the end of the article, you will able to remove package using composer remove command.

Let’s get started.

Remove Package from Laravel

So to remove the package from laravel, we use the composer remove command. This will remove the packages files from the vendor and from the composer.json as well.

composer remove package_name

Step by Step Instructions to Remove package in laravel

Step 1: Remove the package using composer remove command

So the first step is to remove the package using the composer remove command.

Example

So lets I have to remove the package realrashid/sweet-alert. I will type following command in the terminal

composer remove realrashid/sweet-alert

Step 2: Delete package files from config folder

In this step, you need to go the config folder and delete all the files manually for that specific package.

Example

So let’s say I am removing package realrashid/sweet-alert. So I will look for filenames which have package name realrashid or sweet-alert in config folder and will delete them.

Step 3: Delete package tables from database

Most of the laravel package have some tables created in the database at the time of installation to store data and information.

So you might need to go to the database and search for the table which have prefix or suffix same as the package name.

Example

So lets again assume i am remove the package realrashid/sweet-alert. So i will check the tables in database if any table name starts or ends with realrashid or sweet-alert and will delete them.

Step 4: Remove package providers and aliases from config/app.php

Now the last step, we would remove the providers and aliases from the config/app.php file.

These providers and aliases might added manually by you after the installation of the package.

So go to the config/app.php and search for the package name in the providers and aliases array.

Example

So once again let’s assume I am removing the package realrashid/sweet-alert. So I will search for again suffix or prefix that match with package name.

'providers' => [
..............
SweetAlert\Namespace\SweetAlert::Class
..............
]

'aliases' => [
..............
'SweetAlert'=> SweetAlert\Namespace\SweetAlert::Class
..............
]

Conclusion

In the above article, we have discussed step by step how to remove the package from the laravel. By this guide you can easily remove the package from laravel using the composer remove command.

Hope you like it. Let me know if you have any questions 🙂

See you soon and Happy Coding 🙂

Write a Reply or Comment

Your email address will not be published. Required fields are marked *


Icon