-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[RFC] A different way of adding annotations support? #33164
Comments
Big 👍 for moving (almost) everything from SensioFrameworkExtraBundle about annotation to the core |
@javiereguiluz this would work very well in combination with [RFC] extended controller/route configuration |
Using annotations is such an integral part to how Symfony is best experienced today that I think it makes perfect sense to do this. There is an argument for it to be added to the core, but because they're not currently necessary for Symfony to work, I don't think that we should. |
i would avoid symfony/annotations (it really looks like a annot library :P), in favor of putting them into the component/bridge/bunde they belong to (like |
I agree with @ro0NL on this one. In my scenario the Routing component would provide this feature, so Security bundle/component would provide an annotation for the controller, twig bundle could provide the annotation, etc. This would all be optional, could be a bridge, could be in the bundle directly. |
@ro0NL @linaori let's see if we are talking about the same thing here. The Routing component already includes the If you run If we had a So, if I understood you well, you want to include only the annotation classes but not the annotation library on each component ... so, annotations wouldn't work if you don't install something. It's hard for marketing: Symfony finally includes all annotations in its core ... but ... they don't work ... you have to install something else. 😭 |
@javiereguiluz my goal is eventually the same as yours, no need to depend on the sensio framework extra bundle. In my scenario I do still want the features but might not want to use annotations to use them, hence I think it works well in combination. I'm personally in favor of annotations, hence I'd love to see your solution implemented as well as the end result is definitely better. In my RFC it would make it optional to require the annotations because you could use the same features without annotations for controllers. |
if you run then it's simply matter of pointing the
you'll get those from requiring the component/brdige/bundle, which would be required in the first place to get things to work. So this follows Symfony's "pick what you need" philosophy IMHO. |
@ro0NL yes ... if we move all annotations to different components, then |
It seems to me that is what #25361 propose? |
Anyone willing to move annotations and the related logic from SensioFrameworkExtraBundle to core? |
@nicolas-grekas I've been toying with the idea to store the information of the annotations -or controller config for that matter-, somewhere in the Route definition. Would that be an okay way to go? This would utilize the router cache for the configuration and it can be populated in the request attributes. This would keep behavior the same as with the extra bundle and provide this information anywhere during the request life-cycle. Is this something I should continue working upon? |
nothing shocking to me, it looks like that's what options are fore, isn't it? |
Yes, they could be stored within route options and then populated in the request. My only concern is a possible collisions in naming/storage, which made me look into alternatives. Storing it somewhere else makes it a lot more complicated though. I'll play around with what I have to see if I can make something out of it, though I believe this can be done together with Javier's suggestion. |
Route options are available for the routing dumpers, but they are not available at runtime. So they don't look like the solution here. @javiereguiluz the main argument you have is that SensioFrameworkExtraBundle installs too many dependencies. I think the easy fix here is to make |
Anyone up for a PR? |
I might be able to help out... but what exactly should be done? 😊 I'm a bit lost with the discussion here 😕 |
I think @stof has the correct hint:
|
Do we reopen symfony/symfony-docs#10426 then? |
This PR was merged into the 5.4.x-dev branch. Discussion ---------- rm dependency on doctrine/persistence See symfony/symfony#33164 - make `doctrine/persistence` optional since it will be required transitively anyway via the ORM/ODM that is required for using `DoctrineParamConverter` Commits ------- 80e03da rm dependency on doctrine/persistence
Closing because this will be "soon" irrelevant because annotations will be native starting from PHP 8. Thanks! |
This PR was merged into the 5.4.x-dev branch. Discussion ---------- rm dependency on doctrine/persistence See symfony/symfony#33164 - make `doctrine/persistence` optional since it will be required transitively anyway via the ORM/ODM that is required for using `DoctrineParamConverter` Commits ------- 80e03da rm dependency on doctrine/persistence
Description
On Twitter (see https://twitter.com/symfonydocs/status/1161220549785391104) there was a discussion about why we recommend to run
composer require annotations
in the Symfony routing docs.This is what we recommend today:
This is what happens with another command:
Both solutions work ... and the second solution looks better because it installs less packages ... but there's an important drawback of the second solution: none of the SensioFrameworkExtraBundle annotations will be installed, such as the ParamConverter ones.
There are related discussions like #25361 that proposes to add annotations to core.
In this issue I'm proposing another solution:
symfony/annotations
packagedoctrine/annotations
internally of course (we're not going to reinvent an annotation library)This way:
What do you think?
The text was updated successfully, but these errors were encountered: