📜  控制器中的 symfony 调用服务 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:10.641000             🧑  作者: Mango

代码示例1
$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();
    }