Skip to content

[FrameworkBundle] Deprecate doctrine/annotations integration #50888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Jul 5, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? yes
Tickets N/A
License MIT
Doc PR TODO

This PR deprecates the integration of the doctrine/annotations package in FrameworkBundle. Currently, the integration is enabled by default if doctrine/annotations is installed. This PR adds a runtime deprecation if the app does not explicitly disable it by setting:

framework:
    annotations: false

The plan is to make this the default and only valid option in Symfony 7 and remove that setting entirely in Symfony 8. This change unlocks #49358 and similar PRs that remove support for Doctrine Annotations from components.

@derrabus derrabus force-pushed the deprecate/annotations branch 4 times, most recently from 7741661 to 336d0a1 Compare July 5, 2023 13:10
@derrabus derrabus force-pushed the deprecate/annotations branch 2 times, most recently from 45a4183 to 3387235 Compare July 5, 2023 14:39
@GromNaN
Copy link
Member

GromNaN commented Jul 5, 2023

I don't have the whole thing in my head. Is it necessary to add the framework.annotations.enabled: false config when the doctrine/annotations package is not detected?

Self-reply: it's documented in FrameworkBundle's changelog.
Thanks.

@derrabus derrabus force-pushed the deprecate/annotations branch from 3387235 to e0b4c95 Compare July 5, 2023 15:04
@derrabus
Copy link
Member Author

derrabus commented Jul 5, 2023

Is it necessary to add the framework.annotations.enabled: false config when the doctrine/annotations package is not detected?

No.

Long answer: Unfortunately, we currently enable the annotations integration by default if the doctrine/annotations package is installed. However if the package is not installed, FrameworkBundle's default behavior is fine, so you don't have to opt out of anything.

@stof
Copy link
Member

stof commented Jul 5, 2023

@derrabus regarding the "unlocking" part, shouldn't we actually first deprecate annotations in components and then deprecate the FrameworkBundle integration configuring a reader only once we don't rely on it anymore ?

@derrabus
Copy link
Member Author

derrabus commented Jul 5, 2023

shouldn't we actually first deprecate annotations in components and then deprecate the FrameworkBundle integration configuring a reader only once we don't rely on it anymore ?

That was my first approach, but I think it's easier this way. This PR is self-contained: If we merge it and remove the integration in 7.0, the components might still support Doctrine annotations, but FrameworkBundle won't have a way to enable them. Removing a feature that FrameworkBundle doesn't use should be easy. 🙂

@stof
Copy link
Member

stof commented Jul 5, 2023

@derrabus but the DX would be worse as devs would not get deprecation warnings telling them where they still use annotations, which they should solve before disabling them.
To me, we should first have a component-level deprecation triggered when annotations are actually found (so in the case of the routing component, triggered when you actually have a route defined with annotations).

@derrabus derrabus force-pushed the deprecate/annotations branch from e0b4c95 to bbb95eb Compare July 14, 2023 09:17
@derrabus
Copy link
Member Author

derrabus commented Jul 14, 2023

@derrabus but the DX would be worse as devs would not get deprecation warnings telling them where they still use annotations, which they should solve before disabling them.

#49358, #50982 and #50983 trigger the deprecations you want.

To me, we should first have a component-level deprecation triggered when annotations are actually found (so in the case of the routing component, triggered when you actually have a route defined with annotations).

This is kinda a chicken-egg problem. I'm working on removing annotations everywhere and I believe we both agree on how the end result should look like. Unless we want to discuss a big all-or-nothing PR, I think we can live with this DX flaw, knowing we will resolve it before 6.4.

@derrabus derrabus force-pushed the deprecate/annotations branch 3 times, most recently from ea0b7a2 to 6ef6b5b Compare July 15, 2023 22:07
@derrabus derrabus force-pushed the deprecate/annotations branch from 6ef6b5b to 1d3e0c6 Compare July 16, 2023 17:45
@nicolas-grekas nicolas-grekas force-pushed the deprecate/annotations branch from 1d3e0c6 to 2b3c954 Compare July 20, 2023 10:11
@nicolas-grekas
Copy link
Member

Thank you @derrabus.

@nicolas-grekas nicolas-grekas merged commit 02147d3 into symfony:6.4 Jul 20, 2023
@derrabus derrabus deleted the deprecate/annotations branch July 20, 2023 13:43
nicolas-grekas added a commit that referenced this pull request Jul 24, 2023
…ion (derrabus)

This PR was merged into the 7.0 branch.

Discussion
----------

[FrameworkBundle] Remove doctrine/annotations integration

| Q             | A
| ------------- | ---
| Branch?       | 7.0
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Follows #50888
| License       | MIT
| Doc PR        | TODO, see symfony/symfony-docs#18589

Commits
-------

713ff44 [FrameworkBundle] Remove doctrine/annotations integration
nicolas-grekas added a commit that referenced this pull request Jul 24, 2023
…tes (derrabus)

This PR was merged into the 6.4 branch.

Discussion
----------

[Serializer] Deprecate annotations in favor of attributes

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | Follows #50888
| License       | MIT
| Doc PR        | TODO, see symfony/symfony-docs#18589

This PR deprecates using Doctrine annotations to configure serialization. Attributes shall be used instead.

Existing applications can be migrated easily using [Rector](https://getrector.com/blog/how-to-upgrade-annotations-to-attributes).

Deprecation errors triggered by the bundles' functional tests will be resolved once #50888 is merged.

Commits
-------

9b7b397 [Serializer] Deprecate annotations in favor of attributes
symfony-splitter pushed a commit to symfony/serializer that referenced this pull request Jul 24, 2023
…tes (derrabus)

This PR was merged into the 6.4 branch.

Discussion
----------

[Serializer] Deprecate annotations in favor of attributes

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | Follows #50888
| License       | MIT
| Doc PR        | TODO, see symfony/symfony-docs#18589

This PR deprecates using Doctrine annotations to configure serialization. Attributes shall be used instead.

Existing applications can be migrated easily using [Rector](https://getrector.com/blog/how-to-upgrade-annotations-to-attributes).

Deprecation errors triggered by the bundles' functional tests will be resolved once symfony/symfony#50888 is merged.

Commits
-------

9b7b397ec4 [Serializer] Deprecate annotations in favor of attributes
nicolas-grekas added a commit that referenced this pull request Jul 24, 2023
…es (derrabus)

This PR was merged into the 6.4 branch.

Discussion
----------

[Validator] Deprecate annotations in favor of attributes

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | Follows #50888
| License       | MIT
| Doc PR        | TODO, see symfony/symfony-docs#18589

This PR deprecates using Doctrine annotations to configure validation constraints. Attributes shall be used instead.

Existing applications can be migrated easily using [Rector](https://getrector.com/blog/how-to-upgrade-annotations-to-attributes).

Deprecation errors triggered by the bundles' functional tests will be resolved once #50888 is merged.

Commits
-------

6b6dc62 [Validator] Deprecate annotations in favor of attributes
nicolas-grekas added a commit that referenced this pull request Jul 24, 2023
… (derrabus)

This PR was merged into the 6.4 branch.

Discussion
----------

[Routing] Deprecate annotations in favor of attributes

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | Follows #50888
| License       | MIT
| Doc PR        | TODO, see symfony/symfony-docs#18589

This PR deprecates the integration of Doctrine Annotations for the Routing component.

Attributes are the way to go now if we want to annotate controllers with routing information. Existing applications can be migrated easily using [Rector](https://getrector.com/blog/how-to-upgrade-annotations-to-attributes).

Thus I believe that keeping support for oldschool Doctrine Annotations is not necessary anymore.

If this PR is accepted, I would work on a follow-up that renames all `Annotation*Loader` classes because the names of those classes are probably misleading as soon as they support attributes only.

Commits
-------

6ce15f2 [Routing] Deprecate annotations in favor of attributes
This was referenced Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants