php bin/console security:encode-password
Encode a password
Usage
security:encode-password [--empty-salt] [--] [<password> [<user-class>]]
Arguments
password The plain password to encode.
user-class The User entity class path associated with the encoder used to encode the password.
Options
--empty-salt Do not generate a salt or let the encoder generate one.
Help
The security:encode-password command encodes passwords according to your
security configuration. This command is mainly used to generate passwords for
the in_memory user provider type and for changing passwords
in the database while developing the application.
Suppose that you have the following security configuration in your application:
# app/config/security.yml
security:
encoders:
Symfony\Component\Security\Core\User\InMemoryUser: plaintext
App\Entity\User: auto
If you execute the command non-interactively, the first available configured
user class under the security.encoders key is used and a random salt is
generated to encode the password:
php bin/console security:encode-password --no-interaction [password]
Pass the full user class path as the second argument to encode passwords for
your own entities:
php bin/console security:encode-password --no-interaction [password] 'App\Entity\User'
Executing the command interactively allows you to generate a random salt for
encoding the password:
php bin/console security:encode-password [password] 'App\Entity\User'
In case your encoder doesn't require a salt, add the empty-salt option:
php bin/console security:encode-password --empty-salt [password] 'App\Entity\User'