Bonjour, j’essaie d’encoder les mots de passe comme la documentation l’indique : https://symfony.com/blog/new-in-symfony-5–3-passwordhasher-component.
je vous envoies mon code ci-dessous :
<?php
namespace App\Controller;
use App\Form\RegisterType;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\PasswordHasher\PasswordHasherInterface;
class RegisterController extends AbstractController
{
/**
* @Route("/inscription", name="register")
*/
public function index(Request $request,EntityManagerInterface $doctrine,PasswordHasherInterface $encoder) : response
{
$user = new User();
$form = $this->createForm(RegisterType::class,$user);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()){
$user=$form->getData();
$doctrine->persist($user);
$doctrine->flush();
dd($user);
}
return $this->render('register/index.html.twig',[
'form' => $form ->createView()
]);
}
}
et mon message d’erreur :
Cannot autowire argument $encodage of "App\Controller\RegisterController::index()": it references interface "Symfony\Component\PasswordHasher\PasswordHasherInterface" but no such service exists. Did you create a class that implements this interface?
Merci pour votre aide
Modification par @Amaury : mise en forme Markdown (n’hésite pas à modifier ton message pour voir comment j’ai fait).
+0
-0