I am writting a login app with Silex, but I have a problem with Silex password encoder. I read this in the silex document and got some code like this:
// find the encoder for a UserInterface instance
$encoder = $app['security.encoder_factory']->getEncoder($user);
// compute the encoded password for foo
$password = $encoder->encodePassword('foo', $user->getSalt());
But when I access my website in the first time, I don't have a $user varirable. Where can I get the $user varirable to encode my password?
UPDATE MY SOLUTION
Finally, I found a solution. This is my code to get encoded password:
$encoded = $app['security.default_encoder']->encodePassword($string, '')