2
我正在寫一個Silex的登錄應用程序,但我有一個Silex密碼編碼器的問題。我的硅石文檔閱讀,並得到一些像這樣的代碼:如何在Silex中編碼密碼?
// 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());
但是,當我訪問我的網站在第一時間,我沒有$用戶varirable。我在哪裏可以獲得$用戶可變編碼我的密碼?
更新我的解決方案
最後,我找到了解決辦法。這是我的密碼編碼:
$encoded = $app['security.default_encoder']->encodePassword($string, '')