我想在登录后运行自定义 symfony2 控制台命令后台。我做了一个监听器并尝试使用该进程在后台运行命令,但该功能无法正常工作。这是我的代码
class LoginListener
{
protected $doctrine;
private $RecommendJobService;
public function __construct(Doctrine $doctrine)
{
$this->doctrine = $doctrine;
}
public function onLogin(InteractiveLoginEvent $event)
{
$user = $event->getAuthenticationToken()->getUser();
if($user)
{
$process = new Process('ls -lsa');
$process->start(function ($type, $buffer) {
$command = $this->RecommendJobService;
$input = new ArgvInput();
$output = new ConsoleOutput();
$command->execute($input, $output);
echo "1";
});
}
}
public function setRecommendJobService($RecommendJobService) {
$this->RecommendJobService = $RecommendJobService;
}
}
我的代码有问题吗?谢谢帮助。