hj4n3w
Last Updated: February 25, 2016
·
7.431K
· jrgns

Simple Random Password in Symfony 2

From withing a Controller, do the following to get a random 12 digit alphanumeric password:

$tokenGenerator = $this->container->get('fos_user.util.token_generator');
$password = substr($tokenGenerator->generateToken(), 0, 12);

1 Response
Add your response

6127

You should mention that if someone uses this he needs FOSUserBundle too.

over 1 year ago ·