I've currently installed a package "watson/sitemap". Now, I want to remove it without using "composer update" since it will update other packages which I don't want.
Any help would be much appreciated.
To update your packages json file is. Run composer update (on your local machine) to update the required packages and re-generate a composer. lock file. Commit the updated composer.
composer update will update our dependencies as they are specified in composer. json . Supposing we have actually installed the 2.0. 1 version of the package, running composer update will cause an upgrade of this package (for example to 2.0.
You could script this by using Composer's PHP classes or by parsing the composer.lock file, but this is a manual process you can follow. 1. Remove the unwanted package (s) 2. Look for orphaned dependencies composer show -N | xargs -n 1 composer why | grep "There is no installed package"
Removing a package from Laravel using composer. To remove a Laravel package, we just need to run a single command: composer remove spatie/laravel-sitemap Change the spatie/laravel-sitemap with the name of the package that you want to remove. This will remove the line from your compser.json file and also the files from the vendor folder.
Now just go to the directory in which your composer.json file is there and then type the below command: Output: This command removed the stripe/stripe-php dependency from the composer as shown below:
Simply manually remove the “kartik-v/yii2-date-range”: “dev-master” line from the composer.json and save then run composer update in the terminal. In the terminal, just run this command after removing the extension information in the composer.json.
UPDATE: Composer 2 is now out, and it seems to be smart enough to handle the recursion. You need only remove the offending package.
I recently needed to do this. Here's a real-world example. This is pretty hacky. You could script this by using Composer's PHP classes or by parsing the composer.lock
file, but this is a manual process you can follow.
composer remove --no-update illuminate/mail
composer update illuminate/mail
composer show -N | xargs -n 1 composer why | grep "There is no installed package"
Output (something like this):
There is no installed package depending on "erusev/parsedown"
There is no installed package depending on "swiftmailer/swiftmailer"
There is no installed package depending on "tijsverkoyen/css-to-inline-styles"
composer update erusev/parsedown swiftmailer/swiftmailer tijsverkoyen/css-to-inline-styles
Repeat steps 2 and 3 until you've found all the orphans.
Clarification: If you use the --no-update
flag, you won't upgrade packages... however (as of writing, early 2020) it also does not remove orphaned dependencies. You're not telling it not to "upgrade". You're telling it not to update any of the installed (composer.lock
) dependencies. Big difference. This is why you have to find them and manually "update" them out of your project.
composer remove watson/sitemap --no-update
From CLI Docs:
The remove command removes packages from the composer.json file from the current directory.
php composer.phar remove vendor/package vendor/package2
After removing the requirements, the modified requirements will be uninstalled.
Remove the entry from composer.json then run
composer update watson/sitemap
This will remove a package totally from composer.lock and /vendor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With