Skip to content

Upgrade path from v2 to v3 #5620

Description

@n-valverde

API Platform version(s) affected: 2.7

Description
Hello,

I am currently migrating a big application from v2 to v3, and I am a bit disappointed by how hard the upgrade path is.
I truly understand the intentions of the v3, but I think the upgrade path from v2 should receive more attention, as there is probably a lot of app still in v2 out there. That leads me to the first point:

  • While api-platform follows Symfony's BC promise, it does not follow the same release strategy, i.e the v2.7 is not considered "long-term".

I don't want to bring a debate about LTS, but I do want to highlight that the documentation clearly states that 2.7 is maintained for security fixes only, which leaves people like me understanding that nothing will get fixed in 2.7, even if that prevents a smooth upgrade path.
That's probably not completely true, and I'm assuming maintainers are judging on a case by case basis, but I also came across a few closed issues were the output was: it's 2.7 so won't fix.
But today, @mtarld gave a nice little talk, where he said you would happily accept contributions to improve the upgrade path 😄 so here I am, still confused but optimistic 😄.

So first question: can we contribute on v2.7 to improve the upgrade path? If yes, can we update the documentation to make it clear the api-platform is not leaving people behind. I'd be happy to contribute, but as I said right now I'm just confused on whether we can contribute to 2.7 or not.

If the answer of the above is no, no need to read further 🙃

The below is a summary of issues I've encountered so far and where I'd be happy to contribute, just don't want to spam new issues

  • bin/console api:upgrade-resource

That command is mostly broken, because it completely mess up the formatting, and cs-fixer is clearly not enough to fix the mess. In a big application, where the command needs to alter roughly 200 files, that's an issue. It currently alter source code, while it's supposed to deal with annotations and attributes, but is adding/removing parenthesis in method bodies, adding/removing whitespaces and blanklines litterally everywhere.

I left a little fix for that in another closed issue (not perfect but enough to make the command usable). But that also brings the question of: why not just rector?

  • Rector rules

Apart from the above question of why not rector for the upgrade resource command, I am also confused to not find any rector rule out there helping with the namespace updates. There are a lot of namespace changes, some are very simple to fix, others pretty hard, but it would be nice to have some rector rules to help. Did I miss them somewhere?

I would love to find a, let's say rector/rector-api-platform for example 😄

  • Unsolvable deprecations

While the upgrade path should be to resolve deprecations prior to turning any BC flag off (or to upgrade to next major), api-platform currently throw deprecations that are purely not solvable.
Because of the new metadata system and the BC layer, the services available in the container are different with BC flag on or off.
That leads to situation where you cannot get rid of the deprecation, because the service you need is purely not available, so you have to turn that BC flag off, and your whole app explode (makes sense) and then you cannot fix smoothly the deprecation. That leads to bigbang upgrade situation, which I am currently living 🙃 , and this is mostly why major upgrades ends up being postponed forever in companies.

One good exemple of that is the new IriConverterInterface, which basically cannot be injected with BC flag on, leading to a type error because the container is injecting the old service, which does not implement the interface you're trying to inject.

Another good example of that is userland service decoration, where in some cases you can't decorate the new services because they're basically not available, so can't fix deprecation.

There are probably other examples, I am still in the upgrade path trying to solve issues one by one 🙃

  • Documentation issues

Some deprecation messages are very unclear, and the documentation does not really help. The best example I have for that is

Since api-platform/core 2.7: An anonymous resource will use a Skolem IRI in API Platform 3.0. Use #[ApiProperty(genId: false)] to keep this behavior in 3.0

Api-platform documentation never mentions what an anonymous resource is, and only mention once the Skolem iri. It's really hard to understand if any action should be taken by the user about this deprecation (and AFAIK, most users can just ignore this right?)

I did not find the alternate method for php8.0 that @mtarld showed us today in the documentation, did I miss it? I only found documentation using attributes with new in initializers, which cannot be used prior to php8.1

Also, the upgrade guide has some updates in its 3.1 version, which are not there if you read the upgrade guide on 2.7 🙃

  • Final thoughts

Thanks for reading 😄 , I truly hope we can make that upgrade path better 🤞
Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions