-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
The dependency on doctrine/annotations should become optional #2683
Comments
See #2554 as it has a more complete rundown of where the issues lie. |
since this issue has been created, support for attributes has been implemented.
To me, the main blocker is actually the support for PHP 7.x. Maybe it is time to bump the min PHP version to 8.0 (or maybe 8.1 to be able to use enums in #2675 instead). Note also that doctrine/orm 3.0 is dropping the annotation driver entirely, so you will have to do this migration to attributes before supporting ORM 3.0 (or making a conditional migration) |
#2559 deals with the helpers. As you pointed out, attributes exist now, and leaving the annotations in place won't hurt anything for the time being, so that one's adequately covered for now. I think realistically the remaining hard dependencies are the non-nullable |
Any update on this? I don't think Symfony 7 will even support it. |
Symfony won't have a native annotations reader but it won't block your project from upgrading. If you're manually configuring services as your pre-edit comment suggests, you can use the |
Is there an alias for that? I can't seem to find it. What should @annotation_reader be? services:
gedmo.listener.timestampable:
class: Gedmo\Timestampable\TimestampableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ '@annotation_reader' ] ]
|
I'm hacking in services.yaml, but this is a bit of a mystery to me: attr_reader: "@Gedmo\\Mapping\\Driver\\AttributeReader"
Gedmo\Mapping\Driver\AttributeReader:
alias: attribute_reader Etc. It seems like this would be better as the default, and someone could set the annotation reader if they were using them. There was a significant refactoring of this bundle a while ago to support attributes. I'm mostly trying to silence deprecation warnings, which are practically blocking the real issues. |
This package on its own doesn't provide a Symfony bundle, so that attribute reader won't be automatically set up in a Symfony app (if you're using As for the Symfony deprecation, on top of updating your service configs for the classes from this package, you'll also need to check your other app services and third-party integrations to see if they have a hard requirement on the |
My bundle does not yet handle that, because I just discovered the AttributeReader class in that discussion. But I will definitely handle that in the bundle directly ASAP. |
@mbabker there is still one place with a hard dependency: |
|
@mbabker sure. but forcing the package to be installed is what will cause issues once the Doctrine team marks |
I'll PR this later, but main...mbabker:DoctrineExtensions:default-reader might be enough to solve that one, too (builds on the same logic as #2559 for deciding defaults). |
@mbabker this is not the right approach IMO. This default reader will impact the kind of mapping that can be used in project-level entities for the Gedmo mapping. Passing an AttributeReader on PHP 8 would disable the support of annotations on PHP 8 by default, which is a BC break. When doctrine/annotations is installed, the default reader should support annotations. The ExtensionMetadataFactory will make sure to enable support for both annotations and attributes when the provided reader is an annotation reader. This is different than the ORM mapping driver used for entities defined in the library. For those, we know that both attributes and annotations are provided and we can use either of them with the same result so preferring attributes on PHP 8 is fine. |
Alternatively, we could make the default annotation reader nullable in the factory, letting it create an AttributeDriver when needed. |
I can flip the order on the checks if that'll fix things. Otherwise it turns into a much bigger review trying to make the reader nullable where it's currently not. That was just a very quick idea to push up to see if it's even viable. |
flipping the conditions should indeed be enough |
#2713 to iterate on the fallback default behavior for the base subscriber class. |
Unless I'm missing something, I think #2728 is the last PR needed before |
May be, but |
Well aware. It'll be updated in due time. |
#2735 would be the last step here and probably needs the most testing out of every PR that's been involved in decoupling this dependency. |
How about a new version that required attributes, and didn't support annotations at all? That is, if someone needed to use annotations, they'd use the current version of the bundle, and the next one could only support Symfony 6.3+? We could deprecate the use of annotations in this version for developers to prepare. |
It'll happen eventually (especially as Doctrine is deprecating annotations support entirely, including the package used for reading them), it just doesn't need to happen right now (or even anytime soon-ish; both the ORM and MongoDB ODM libraries support annotations on their current majors, and ORM 3 support is still a ways off here, so to me there isn't a need to rush to drop annotation support entirely just yet). Not to mention that there is a LOT of work in the tests that needs to happen so those can run without requiring annotation support. |
okay. I thought it might be easier to drop annotations altogether than to support it as an option. |
I'm on Symfony 7 and the My workaround was to modify my kernel as follows: class Kernel extends BaseKernel
{
use MicroKernelTrait;
protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new class() implements CompilerPassInterface {
public function process(ContainerBuilder $container): void
{
$container->register('gedmo_attribute_reader',\Gedmo\Mapping\Driver\AttributeReader::class);
$container->getDefinition('stof_doctrine_extensions.listener.timestampable')
->addMethodCall('setAnnotationReader',[
new Reference('gedmo_attribute_reader')
]);
}
});
}
} Ideally it shouldn't require this workaround. Hopefully this will help anyone else who runs into this issue. |
The patches making the annotation reader 100% optional haven't released yet. Plus, for B/C, when |
Feature Request
For projects that have migrated from annotations to attributes (as recommended by the Doctrine team), the
doctrine/annotations
package is unnecessary.As the Doctrine team is planning to mark the
doctrine/annotations
package as abandoned (see doctrine/annotations#485), it would be great if this package could stop being a mandatory dependency of the extensions.The text was updated successfully, but these errors were encountered: