Is there a way to uninstall dev dependencies with composer?

PhpComposer Php

Php Problem Overview


I want to uninstall (and not remove from my composer.json) dev dependencies on a project.

Is there a simple way to do this ?

Php Solutions


Solution 1 - Php

Running install or update with --no-dev should now remove dev requirements and their dependencies.

Original answer for historical purposes:

>Actually no. You can manually rm -rf them from the vendor dir of course, but composer offers no way to uninstall the dev requirements after you did an install with --dev. It's not a huge use case but could warrant a new command line switch, if you would like to report an issue on github.

Solution 2 - Php

You can use following command after removing the dependencies in composer.json file.

composer update

Solution 3 - Php

Came over this question when looking for the same answer. You can now uninstall installed dev dependencies by simply doing:

composer --no-dev update

It will remove all dev packages that it finds. Though it would interest people landing here the same way I did :)

Solution 4 - Php

This is not the strict answer but may help someone.

To remove a specific dev dependency:

composer remove --dev squizlabs/php_codesniffer

Solution 5 - Php

I answered later but it could help someone else: composer remove friendsofsymfony/elastica-bundle (for example)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYohan G.View Question on Stackoverflow
Solution 1 - PhpSeldaekView Answer on Stackoverflow
Solution 2 - PhpKoray GüclüView Answer on Stackoverflow
Solution 3 - PhpBlizzView Answer on Stackoverflow
Solution 4 - PhpSandroMarquesView Answer on Stackoverflow
Solution 5 - PhpWilliam RossierView Answer on Stackoverflow