M
M
magary42017-03-03 18:27:18
symfony
magary4, 2017-03-03 18:27:18

How does Symfony inject a Request into a controller if it is given as a parameter?

if you write like this

public function indexAction(<b>Request $request</b>)
{

}

the request will be available in the method
how to make if the
indexAction(Request $request, MyService $ms) method
so that my service instance is automatically fired and available inside the method?
and how good practice is it to inject into a method and not into a constructor?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2017-03-03
@miraage

Great practice. And automatic injection is done by autowire.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question