Skip to content
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

chore(deps): Make doctrine/annotations optional #77

Conversation

WedgeSama
Copy link

With PHP attributes, doctrine/annotations become non require for this bundle to work. The requirement on this dep is now unnecessary.

Still give the capability to keep it I you wanted to.

PS: This become problematic when trying to update projects that use dependencies that become incompatible with doctrine/annotations.

@nayzo
Copy link
Owner

nayzo commented Feb 11, 2025

@WedgeSama, In what cases is doctrine/annotations problematic?
Sure, it's required, but you can choose not to use it and rely entirely on PHP 8 attributes. The use of annotations is not mandatory.

I'm curious to know what issues you encountered when not using annotations.

Thank you!

@WedgeSama
Copy link
Author

Of course, here the case:

Unfortunately, when using doctrine/doctrine-bundle, you cannot fully rely on attributes if the package doctrine/annotations is in your dependencies.

As you can see here in the DoctrineBundle DependencyInjection/DoctrineExtension#L488 , its rely on the existence of the class Doctrine\Common\Annotations\Annotation to enable or not annotation support.
=> You cannot choose to disable it, except if you remove it from your dependencies.

The case append with gedmo/doctrine-extensions that have some problem with ORM3 when using both annotation and attribute, more info here: ORM 3.0 compat

The best solution is to switch to attributes and completely remove doctrine/annotations, but this is not possible when also using your bundle 😢

#################

Plus 1: Your bundle is already fully compatible with attributes only, so why not remove it from dependencies?

Plus 2: Quoted from doctrine/annotations repository: We do not recommend using this library in new projects and encourage authors of downstream libraries to offer support for attributes as an alternative to Doctrine Annotations.

Plus 3: The lib will be flagged as abandoned: doctrine/annotations#485

#################

Hope im clear, do not hesitate to ask if you need more info 😉

@nayzo
Copy link
Owner

nayzo commented Feb 11, 2025

The annotation support is enabled, but that doesn’t mean you have to use it instead of attributes. PHP attributes were introduced in PHP 8.0, so for those using older PHP versions (7.x) the annotation package is required. The bundle must maintain this compatibility and avoid breaking changes. It fully supports both annotations and attributes.

I’ve been working on an alternative approach to address this issue and will push my changes as soon as possible.

@nayzo
Copy link
Owner

nayzo commented Feb 14, 2025

@nayzo nayzo closed this Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants