symfony / flex

Composer plugin for Symfony
MIT License
4.16k stars 181 forks source link

Sort classes on bundles.php #275

Closed soullivaneuh closed 6 years ago

soullivaneuh commented 6 years ago

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.

greg0ire commented 6 years ago

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.

fabpot commented 6 years ago

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.

GPHemsley commented 4 years ago

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.

fabpot commented 4 years ago

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

alexander-schranz commented 4 years ago

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.

stof commented 3 years ago

@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.