Symfony Call Service In Controller

[Solved] Symfony Call Service In Controller | Php Frameworks Symfony - Code Explorer | yomemimo.com
Question : symfony call service in controller

Answered by : hassan-elshazly-eida

$this->container->get('service_name');
// This work on for Symfony\Bundle\FrameworkBundle\Controller\Controller
// if you are using use Symfony\Bundle\FrameworkBundle\Controller\AbstractController , it would prefer to inject dependency public function method(User $user) { $user->callSomeMethod(); }

Source : | Last Update : Mon, 06 Dec 21

Answers related to symfony call service in controller

Code Explorer Popular Question For Php Frameworks Symfony