Flex: Sort classes on bundles.php

Created on 8 Jan 2018  路  6Comments  路  Source: symfony/flex

My current bundles.php, touched only by Flex:

return [
    Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
    FOS\UserBundle\FOSUserBundle::class => ['all' => true],
    HWI\Bundle\OAuthBundle\HWIOAuthBundle::class => ['all' => true],
    Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
    EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
    Knp\Bundle\MarkdownBundle\KnpMarkdownBundle::class => ['all' => true],
    OldSound\RabbitMqBundle\OldSoundRabbitMqBundle::class => ['all' => true],
    Http\HttplugBundle\HttplugBundle::class => ['all' => true],
    Sensio\Bundle\DistributionBundle\SensioDistributionBundle::class => ['all' => true],
    Sonata\IntlBundle\SonataIntlBundle::class => ['all' => true],
    Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
    Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
    Liip\FunctionalTestBundle\LiipFunctionalTestBundle::class => ['dev' => true, 'test' => true],
    Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle::class => ['dev' => true, 'test' => true],
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
];

It would be great to have Symfony Flex sorting the list while adding a new element.

Or at least, an option for it, like the composer sort-packages one.

All 6 comments

That might be dangerous, because the order might matter (I think it should not, but it might). A feature to add the new element in a sorted way if the existing list is itself sorted could be great.

Indeed, we should not sort it. As a developer, you can tweak the order if needed. It should not matter, but some bundles only works with a certain order.

How is flex determining the order now? How is a bundle developer supposed to specify the order in which bundles are listed?

I'm not seeing anything in the recipe spec that would ensure a particular order (since JSON objects are not inherently ordered), for example:

https://github.com/symfony/recipes/blob/master/README.rst#bundles-configurator

And as it stands, the order is generally determined by the order of installation, with new bundles simply being added to the end.

And the file is regenerated from scratch every time anyway (see, e.g., #557), so the app developer would already need to be vigilant about maintaining custom changes to bundles.php after a recipe installation.

As I said above, order should not matter. I would even say that if the order matters, it's a bug in the bundles.

Sometimes a bundle dev doesn't set the correct priority for there compiler passes and so it sometimes needed that you change the order of the bundle in the bundles.php if it depends that another compilerpass of another bundle runs first, sorting could crash exist projects so this should not be done automatically.

@GPHemsley the file is recreated each time (thus loosing comments) but not from scratch. The existing array is loaded and then modified as needed. So the order is preserved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emulienfou picture emulienfou  路  4Comments

shyim picture shyim  路  5Comments

weaverryan picture weaverryan  路  3Comments

javiereguiluz picture javiereguiluz  路  6Comments

Deltachaos picture Deltachaos  路  5Comments