What is the right way to remove a package from Laravel ? Some packages publish their configuration via artisan config:publish … Is there a way to “unpublish” them?
The steps to remove a package from Laravel are:
- Remove declaration from composer.json (in “require” section)
- Remove Service Provider from app/config/app.php (reference in “providers” array)
- Remove any Class Aliases from app/config/app.php
- Remove any references to the package from your code
- Run composer update vendor/package-name. This will remove the package folder from vendor folder and will rebuild composer autoloading map.
- Manually delete the published files
It will remove the package folder from “Vendor” folder
In addition, here are a few more suggestions in case you run into any unforeseen issues.
So even after you have followed all the steps from the above, sometimes it can be that files simply stuck in composer cache and it does not want to update. In that case, you need to clear your composer cache by running the following command in your terminal:
It’s fine if you want to use clear-cache as well, which is an alias for clearcache.
If you ever receive a weird warning message, such as the below, that will be a clear sign that you are having issues with the cache.
there may be a typo in the package name"
After you are ready and have cleared your composer cache, try running
since that will regenerate the lock file and make sure your minimum requirements are full-filled.