SensioFrameworkExtraBundle icon indicating copy to clipboard operation
SensioFrameworkExtraBundle copied to clipboard

Annotations read from cache despite being disabled

Open umulmrum opened this issue 6 years ago • 1 comments

My bundle configuration is as follows:

sensio_framework_extra:
    cache:       { annotations: false }
    request:     { converters:  true }
    router:      { annotations: false }
    security:    { annotations: false }
    view:        { annotations: false }

With this configuration I'd like to disable annotations completely, but still be able to use ParamConverters in controllers (restricted to guessing the converter from the type declaration in the controller method signature).

There isn't a functional problem - works as intended. But the Symfony debug toolbar still shows that there is a call to the cache (cache.annotations) for every controller in the application on every request. I'd like to get rid of those calls.

Looking at SensioFrameworkExtraExtension, annotations are always loaded if converters are active. I played around a bit and it worked as desired if I did these two things:

  • Do not load annotations.xml if only converters are enabled as in the config above.
  • Set framework: annotations: enabled: false in the framework config.

This most likely destroys usage for when annotations should be used in conjunction with ParamConverters, so I'd appreciate a cleaner solution.

umulmrum avatar Sep 07 '18 09:09 umulmrum

TIL: There's a better solution for what I want to achieve: https://symfony.com/doc/current/controller/argument_value_resolver.html (and I found it just after complaining :-) ).

So maybe the ParamResolver is only used in conjunction with annotations and the problem might therefore not exist in practice. My own problem is solved, so feel free to close the issue if you think the current behavior is as intended or "good enough".

umulmrum avatar Sep 07 '18 10:09 umulmrum