How to remove a package from Laravel using composer?
Composer 1.x and 2.x
Running the following command will remove the package from vendor (or wherever you install packages), composer.json and composer.lock. Change vendor/package appropriately.
composer remove vendor/package
Obviously you'll need to remove references to that package within your app.
I'm currently running the following version of composer:
Composer version 1.0-dev (7b13507dd4d3b93578af7d83fbf8be0ca686f4b5) 2014-12-11 21:52:29
Documentation
https://getcomposer.org/doc/03-cli.md#remove
Updates
- 26/10/2020 - Updated answer to assert command works for v1.x and v2.x of Composer
Got it working... The steps to remove a package from Laravel are:
- Remove declaration from composer.json (in "require" section)
- Remove Service Provider from
config/app.php
(reference in "providers" array) - Remove any Class Aliases from
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 thevendor
folder and will rebuild the composer autoloading map. - Manually delete the published files (read the comment by zwacky)
It will remove the package folder from Vendor
folder
Running the following command
composer remove Vendor/Package Name
That's all. No need composer update. Vendor/Package Name is just directory as installed before