I want to run a custom symfony2 console command background after login. I make a listener and try to use the process to run the command at background but the function not work well. Here is my code
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;
}
}
Is there something wrong with my code? Thx for helping.