Sort packages without adding/updating dependencies

I know I'm (really) late! But perhaps my answer can help others in the future ;-)

If you run

composer config sort-packages true

this will add the following in your composer.json file:

    "config": {
        "sort-packages": true
    },

The next time you do a composer require (or update) it will automatically sort the whole list.


You can "re-require" a package you've already required. In my case, it's Symfony 3.4, so I did:

composer require symfony/symfony:3.4.*

If you don't have "sort-packages": true in your composer.json, you can do:

composer require --sort-packages symfony/symfony:3.4.*

From what I can tell, only the require command has the option for sorting packages so it seems you need to require a package for sorting to be applied.

Tags:

Composer Php