Skip to content

[PasswordHasher] Document usage of PasswordHasherFactory #18020

@artyuum

Description

@artyuum

I needed to use the PasswordHasherInterface to hash a plain password (not associated to an entity) but after injecting it, I was getting the following error:

Cannot autowire argument $passwordHasher of "App\Controller\Folder\CreateFolderController()": it references interface "Symfony\Component\PasswordHasher\PasswordHasherInterface" but no such service exists. Did you create a class that implements this interface?

I thought I had to manually configure it in my services.yaml to "link" this interface to a hasher (e.g. SodiumPasswordHasher) but I decided to dig further and ended up on the component's GitHub page. The snippet provided in the README was helpful and I couldn't find it in the Symfony's documentation.

IMHO, it should also be present in the Symfony's documentation to help the people who wants to use this component without necessarily having an user entity.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions