symfony / flex

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

Documentation on Upgrading Symfony, How Flex Works #575

Open brooksvb opened 4 years ago

brooksvb commented 4 years ago

There is a lack of documentation on how to properly use Symfony Flex.

For example, the behavior described in this comment is not documented anywhere: https://github.com/symfony/flex/issues/433#issuecomment-437325751

The guide for upgrading Symfony doesn't describe how to upgrade with Flex: https://symfony.com/doc/current/setup/upgrade_major.html#update-to-the-new-major-version-via-composer

When it comes to composer I was not very familiar with how everything worked, so trying to upgrade Symfony left me with a lot of questions that don't seem to be answered anywhere. I'm thankful that I was able to have someone explain Flex a bit better and how to modify my composer.json to upgrade by asking in Slack. But this should be available in documentation.

nicolas-grekas commented 4 years ago

Could you please list the specific things you missed and you learned in the process?

brooksvb commented 4 years ago

This is just going to be a brain dump so it might not be great format and it might not all be strictly relevant to Flex. Here is my composer.json before and after for reference

I was able to be ignorant to how flex worked for a while because all I had to do was composer require X for everything like usual, but now I have some nice quick aliases and it does some auto-magical config stuff for me. The problems arose when I wanted to upgrade Symfony.

Examples of the "odd-ones-out":

symfony/maker-bundle
symfony/orm-pack
symfony/webpack-encore-bundle
symfony/flex

Some key points I learned:

Questions I still have:

I feel maybe there could be a lot of benefit to inexperienced developers to have a page describing the composer.json file included in the skeleton project, and why things are configured that way.

brooksvb commented 4 years ago

Also I just discovered this in the skeleton:

    "flex-require": {
        "symfony/console": "*",
        "symfony/dotenv": "*",
        "symfony/framework-bundle": "*",
        "symfony/yaml": "*"
    },

This seems like a nicer way to separate the Symfony packages, but I didn't even know this existed. Why doesn't Flex move things into this format? What exactly can and can't I put in there?

mikatrash commented 4 years ago

I share @brooksvb interogations. In my mind Flex/Composer interaction is some kind of magic stuff. Recently migrated 4.3 to 4.4, similar upgrade path to my composer.json with the exception on * version on symfony components dependencies, because some compoments were updated to 5.0 if not locked individualy to ^4. A doc about the points he mentionned should be great, or at least explanations.

lyrixx commented 4 years ago

This is also related to https://github.com/symfony/symfony-docs/issues/12698

stof commented 4 years ago
* Am I able to use Flex for similar behavior for my own open source project or framework (managing the versions of many packages)?

no. The Symfony Flex plugin is specific for Symfony packages, for its version filtering behavior

stof commented 4 years ago

flex-require in the skeleton is something which works only during create-project.

The polyfill replacement are not something specific to Flex. It is a standard composer feature that we use here, to avoid installing polyfills packages which are not needed due to the platform requirements (if you require php >= 7.2, symfony/polyfill-php56 will be useless for instance). And here, * is precisely what we want to expose

Examples of the "odd-ones-out":

symfony/maker-bundle
symfony/orm-pack
symfony/webpack-encore-bundle
symfony/flex

these are packages which are not part of the symfony/symfony packages, and so are versionned on their own.

* What exactly is the `symfony.lock`? Why does it seem to duplicate a lot of information from `composer.lock`?

symfony.lock stores info about which packages got their recipes applied. It is the lock file of Flex.

* The upgrade documentation says to update the `symfony/symfony` requirement, but in my case, what do I do?

Where does it say that ? I don't find anything about that in the doc page you linked.

brooksvb commented 4 years ago

@stof

Where does it say that ? I don't find anything about that in the doc page you linked.

It looks like the page got updated since I originally pointed it out.

And here, * is precisely what we want to expose

I don't think I understand this sentence. But RE the polyfills being listed as replace packages, this is to prevent unnecessarily installing them since we have already require a higher php version?


With that I think most of the information I didn't have, I now have. It just needs to be documented. There could still be some details shared about the flex-require key. There is a reference here https://github.com/symfony/flex/pull/520

gggeek commented 3 years ago

Fully agree that more doc on how Flex works and how it can be tweaked would go a long way in making it more palatable to developers who still want to maintain a little control over their applications, or who are wondering wether they could add flex recipes to their existing public bundles.

Non-exhaustive list of questions off the top of my mind:

Radiergummi commented 2 years ago

To add to this, just as @gggeek, I was wondering why exactly recipes must be separated from the package repository. It would be great to include sample configuration and environment variables with my private package, by simply having a recipe manifest inside the repository.
Instead, we need to copy-paste those things manually after the installation.

So I'm curious why the decision was made to externalise the recipe, and whether there's any way to include it with the package instead.

nicolas-grekas commented 2 years ago

Anyone up for sending PRs to the doc and/or improving the README?