A
A
andry_vv2018-12-19 19:25:36
symfony
andry_vv, 2018-12-19 19:25:36

Symfony 4.2, what is the performance of autowiring via @required annotation?

In symfony 4.2, autowiring was introduced via the @required annotation.
It turns out that you can define a trait (LoggedTrait, for example ) and use it in any services, no matter how many.
Is it correct to use injection in this way?
What is the performance, is it faster or slower compared to constructor/setter/property injection?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Flying, 2018-12-19
@Flying

Since the container in Symfony is compiled, this does not affect runtime performance in any way. If you want to check - take a look at what the code for creating your service in the container turns into, all this is in var/cache, there will be a normal setLogger($this->get('logger'))one or something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question