Reputation: 13653
What is the correct way to remove a package from Laravel using PHP Composer?
So far I've tried:
composer update
composer dump-autoload
None of these options are working! What am I missing?
Upvotes: 698
Views: 1231801
Reputation: 16591
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
https://getcomposer.org/doc/03-cli.md#remove-rm-uninstall
remove-rm-uninstall
documentationremove-rm
documentationUpvotes: 1136
Reputation: 135
You can simply do composer remove { name of the package here }
Upvotes: 0
Reputation: 4325
You can do any one of the below two methods:
Running the below command (most recommended way to remove your package without updating your other packages)
$ composer remove vendor/package
Go to your composer.json file and then run command like below it will remove your package (but it will also update your other packages)
$ composer update
Also need to run this command for clearing cache, config etc.
$ php artisan optimize:clear
Upvotes: 27
Reputation: 121
To remove any package in your Laravel project you only need to execute the below command using Composer.
composer remove {packageName}
eg: composer remove maatwebsite/excel
In this command, we are removing maatwebsite/excel
package.
Upvotes: 4
Reputation: 451
Running
composer remove package/name
php artisan optimize:clear
e.g "Composer remove mckenziearts/laravel-notify" works for me while using Laravel 8.
Upvotes: 28
Reputation: 41400
Normally composer remove
used like this is enough:
composer remove vendor/package
But if a Composer package is removed and the "config" cache is not cleaned you cannot clean it. When you try like so
php artisan config:clear
you can get an error In ProviderRepository.php line 208:
Class 'Laracasts\Flash\FlashServiceProvider' not found
This is a dead end, unless you go deleting files:
Laravel 5.6
rm bootstrap/cache/config.php
Laravel 9
rm bootstrap/cache/packages.php
It happens usually on automated deployment, when you copy files of a new release on top of old cache. Even if you cleared the cache before copying. You end up with an old cache and a new composer.json file.
Upvotes: 64
Reputation: 701
You have two solution.
First
Use remove
of composer
.
composer remove *your_package_name*
Second
Delete the line in require from composer.json
and then run update
composer update
After removed, recommend to run below two command.
php artisan cache:clear
php artisan config:clear
Upvotes: 6
Reputation: 618
If this doesn't work "composer remove package/name", you can still remove it manually.
Note : package/name is like spatie etc.
composer install
on your terminalNote : Package File mean is that package that you are looking for. For example, you want to remove Spatie. Then you need to find that with similar name in vendor file and you need to delete it manually.
Your package was removed successfully.
Upvotes: 7
Reputation: 195
To add the packages, the command is to be like:
composer require spatie/laravel-permission
To remove the packages, the command is to be like:
composer remove spatie/laravel-permission
Upvotes: 16
Reputation:
composer remove **your-package-name**
php artisan cache:clear
php artisan config:clear
Upvotes: 3
Reputation: 2711
On Laravel 8.*, the following steps work for me:
Run command composer remove package-name
on the terminal
Remove Provider
and aliases
from file Config/app.php
Remove the related file from the Config folder.
Remove it from your code where you used it.
Upvotes: 4
Reputation: 87
There are quite a few steps here:
{ "require": { "twig/twig": "^3.0" } }
I wish to remove twig 3.0
Now open cmd and run composer remove vendor/your_package_name
as composer remove twig/twig
will remove the package.
As a final step, run composer update
. This will surely give you a massage of nothing to install or update
, but this is important in case your packages have inter-dependencies.
Upvotes: 0
Reputation: 2364
We have come with a great solution. This solution is practically done in Laravel 6. If you want to remove any package from your Laravel Project then you can easily remove the package by following below steps:
Step 1: You must know the package name which you want to remove. If you don't know the complete package name then you can open your project folder and go to the composer.json file and check the name in the require array:
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/passport": "^8.3",
"laravel/tinker": "^2.0"
},
Suppose, here I am going to remove the "fideloper/proxy" package.
Step 2: Open a command prompt with your project root folder directory
Step 3: First of all, clear all cache by the following commands. Run the commands one by one.
php artisan cache:clear
php artisan config:clear
Step 4: Now write the following command to remove the package. Here you need to change your package name instead of my example package.
composer remove fideloper/proxy
Now, wait for a few seconds while your package is removed.
Upvotes: 4
Reputation: 431
Use:
composer remove vendor/package
This is an example:
composer require firebear/importexportfree
composer remove firebear/importexportfree
Finally after removing:
php -f bin/magento setup:upgrade
php bin/magento setup:static-content:deploy –f
php bin/magento indexer:reindex
php -f bin/magento cache:clean
Upvotes: 17
Reputation: 2632
You can remove any package just by typing the following command in the terminal, and just remove the providers and alias you provided at the time of installing the package, if any and update the composer,
composer remove vendor/your_package_name
composer update
Upvotes: 42
Reputation: 3023
Before removing a package from a composer.json declaration, please remove the cache:
php artisan cache:clear
php artisan config:clear
If you forget to remove the cache and you get a "class not found error" then please reinstall the package, clear the cache and remove again.
Upvotes: 23
Reputation: 343
If you are still getting the error after you are done with all the steps in the previous answers, go to your projects, Bootstrap → Cache → config.php. Remove the provider and aliases entries from the cached array manually.
Upvotes: 18
Reputation: 13653
I got it working... The steps to remove a package from Laravel are:
composer update vendor/package-name
. This will remove the package folder from the vendor
folder and will rebuild the Composer autoloading map.It will remove the package folder from the Vendor
folder.
Upvotes: 217
Reputation: 1763
In case the given answers still don't help you remove that, try this:
Manually delete the line in require
from composer.json
Run composer update
Upvotes: 10