Extending AbstractController a good practice? #48161
-
I've got something like this:
This used to work fine, but I'm beta testing Symfony 6.2 and it's new PSR-4 Route loading and now I'm getting this message:
This makes me wonder if extending the AbstractController is considered a good practice. Of course it doesn't contain any business logic, but only some helpers methods. Is extending the AbstractController a good idea? And if not, what's the best way to organize these helper methods? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Perhaps you could list a few of your base controller helper methods? Wanting your own base controller with commonly used methods is quite natural and common but it turns out that there are often other approaches that work better. In some cases, controller listeners might be the way to go. Traits can also be very handy. Hard to tell without specifics. As far as the error goes, I have not tried the new routing stuff but purely as a guess you might try moving your abstract base controller to a completely different directory just to see if the annotation reader is getting confused by the abstract nature of your class. |
Beta Was this translation helpful? Give feedback.
-
Actually the commit which made sure you could extend your own abstract controller is the one which makes it crash today 😅 So yes you should be able to do it. I opened #48168 |
Beta Was this translation helpful? Give feedback.
Actually the commit which made sure you could extend your own abstract controller is the one which makes it crash today 😅
So yes you should be able to do it. I opened #48168