Hash user password without User instance in symfony
问题 As it can be read in the official documentation, the current procedure to manually hash a password in the Symfony framework, is the following: use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; public function register(UserPasswordEncoderInterface $encoder) { // whatever *your* User object is $user = new App\Entity\User(); $plainPassword = 'ryanpass'; $encoded = $encoder->encodePassword($user, $plainPassword); $user->setPassword($encoded); } The encodePassword method