Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

symfony call service in controller

$this->container->get('service_name');

// This work on for SymfonyBundleFrameworkBundleControllerController
// if you are using use SymfonyBundleFrameworkBundleControllerAbstractController , it would prefer to inject dependency
 public function method(User $user)
    {
        $user->callSomeMethod();
    }
 
PREVIOUS NEXT
Tagged: #symfony #call #service #controller
ADD COMMENT
Topic
Name
7+3 =