api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 882 forks source link

Replace doctrine/inflector with symfony/string? #5636

Closed micheh closed 1 year ago

micheh commented 1 year ago

Description
Currently the package doctrine/inflector is used to build the route of a resource. Doctrine updated this package in a patch release to generate a different plural for some words. This means that API Platform built different routes for some entities. The change was later reversed in another patch release, but Doctrine will probably adjust some words again in the next major release. They generally advise to use this package only for one-time text or code generation, where you do not need a stable pluralization: https://github.com/doctrine/inflector/issues/221#issuecomment-1595341265

Maybe it would make sense to replace doctrine/inflector with the symfony/string component, as the generated routes should be more stable and use more advanced pluralization? There was once a pull request to do this, but it was abandoned: https://github.com/api-platform/core/pull/3580

Example
API Resource name: Permission Route using doctrine/inflector:2.0.6: /api/permissions Route using doctrine/inflector:2.0.7: /api/permission Route using doctrine/inflector:2.0.8: /api/permissions

soyuka commented 1 year ago

:+1: to continue that work!

dunglas commented 1 year ago

👍 to deprecate using Doctrine Inflector in core and switch to Symfony too. We’ll have to support Doctrine Inflector until v4 for the sake of backward compatibility, thought.

derrabus commented 1 year ago

Maybe it would make sense to replace doctrine/inflector with the symfony/string component, as the generated routes should be more stable

Symfony's policy on fixing pluralization rules is not that different from Doctrine's. That being said, switching to Symfony String is probably a good move for API Platform.