http://symfony.com/doc/master/bundles/FOSUserBundle/adding_invitation_registration.html
上面的构建实体注册服务之类的按照文档去操作。对应自己的地方稍加修改即可。
运用方法
public function inviteAction() { $em = $this->getDoctrine()->getManager(); $invitation = new Invitation(); $em->persist($invitation); // and then just output your $invitation->getCode() to user // also don't forget to check invitation as sent: $invitation->send() }