What is the correct way to remove a package from Laravel using composer? So far I've tried:
composer.json
(in "require" section)app.php
composer update
composer dump-autoload
None of these options are working! What am I missing?
This question is related to
laravel
laravel-4
package
composer-php
uninstallation
Syntax:
composer remove <package>
Example:
composer remove laravel/tinker
On laravel 8.* I following steps work for me :
Run command composer remove package-name
on terminal
Remove Provider
and aliases
from Config/app.php
Remove related file from Config folder.
Remove from your code where you used .
Remove the package with
composer remove vendorname/packagename
you can check remove package from composer.json - docs
Or you can remove the package name from composer.json
file and run composer update
from within your project directory. I hope it helps.
you can remove any package just by typing follwing command in 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
You can remove any package by typing following command in terminal, and just remove the providers and alias you provided at the time of installing the package and update the composer
composer remove <package_name>
composer update
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
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
To remove a package using composer command
composer remove <package>
To install a package using composer command
composer require <package>
To install all packages which are mentioned in composer.json
composer install
To update packages
composer update
I used these for Laravel project
Normally composer remove
used like this is enough:
$ composer remove vendor/package
but if composer package is removed and 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
$rm bootstrap/cache/config.php
And this is Laravel 5.6 I'm talking about, not some kind of very old stuff.
It happens usually on automated deployment, when you copy files of a new release on top of old cache. Even if you cleared cache before copying. You end up with old cache and a new composer.json.
**
use "composer remove vendor/package"
** This is Example: Install / Add Pakage
composer require firebear/importexportfree
Uninsall / Remove
composer remove firebear/importexportfree
Finaly 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
If you are still getting the error after you have done with all above steps, go to your projects bootstrap->cache->config.php
remove the provider & aliases entries from the cached array manually.
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
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 complete package name then you can open your project folder and go to composer.json
file and check name in require an 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 "fideloper/proxy" package.
Step 2: Open command prompt with your project root folder directory Step 3: First of all clear all cache by following commands. Run 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 your package is removing.
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
this 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.
Got it working... The steps to remove a package from Laravel are:
config/app.php
(reference in "providers" array)config/app.php
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 Vendor
folder
Before removing a package from composer.json declaration, please remove cache
php artisan cache:clear
php artisan config:clear
If you forget to remove cache and you get class not found error then please reinstall the package and clear cache and remove again.
Source: Stackoverflow.com