ChatGPT解决这个技术问题 Extra ChatGPT

How to remove globally a package from Composer?

I ran this command to install globally PHPUnit:

composer global require 'phpunit/phpunit=3.7.*'

Now I want to uninstall globally PHPUnit.

Any ideas?


J
Jakub Zalas

To remove a globally installed package run:

composer global remove phpunit/phpunit

global command lets you to run many commands like install, require or update as if you were running them from the COMPOSER_HOME directory.

Read the related documentation here: http://getcomposer.org/doc/03-cli.md#global

COMPOSER_HOME depends on your system (on Linux it's ~/.composer), see http://getcomposer.org/doc/03-cli.md#composer-home for more details.


Are there any reasons composer global update would not work? I removed a package from my composer.json in .composer and ran the global update but I can still execute the program.
A remove command has been added to composer. See this PR and this commit.
@iisisrael it doesn't work for packages installed globally and this is what this question is about. Thanks for reference though!
Composer supports global remove now. Updated the answer.
W
WiRight

Also you can use another way

cd $HOME/.config/composer

And in composer.json file remove some require positions

After all execute composer update This is a long way, but more clear


I used composer global update
I found this config file at ~/.composer/composer.json in brew installed composer