Bonjour,
Voila je rencontre un petit problème avec mon code, je reçois ce message d'erreur : " Undefined type 'Cocur\Slugify\Slugify'. " ?
il ne reconnait pas Slugify: return (new Slugify())->slugify($this->title);
je suis le tutorial Symfony 4 par l'exemple (3/16): découverte de doctrine
Avez vous une idée ?
Ma version Symfony 4.4
Mon source: Property.php
<?php
namespace App\Entity;
use App\Repository\PropertyRepository;
use Doctrine\ORM\Mapping as ORM;
use Cocur\Slugify\Slugify;
............
.........................
..........................................
public function getSlug(): string
{
return (new Slugify())->slugify($this->title);
}
/**
* @ORM\Entity(repositoryClass=PropertyRepository::class)
*/
Mon source : PropertyController.php :
<?php
namespace App\Controller;
use App\Entity\Property;
use App\Repository\PropertyRepository;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class PropertyController extends AbstractController
{
/**
* @var PropertyRepository
*/
private $repository;
/**
* @var ObjectManager
*/
private $em;
public function __construct(PropertyRepository $repository, EntityManagerInterface $em)
{
$this->repository = $repository;
$this->em = $em;
}
/**
* @Route("/biens", name="property.index")
* @return Response
*/
public function index(): Response
{
return $this->render('property/index.html.twig', [
'current_menu' => 'properties'
]);
}
/**
* @Route("/biens/{slug}-{id}", name="property.show", requirements={"slug": "[a-z0-9\-]*"})
* @return Response
*/
public function show($slug, $id): Response
{
$property = $this->repository->find($id);
return $this->render('property/show.html.twig', [
'property' => 'property',
'current_menu' => 'properties'
]);
}
}
j'ai le meme problème comme ça , je pense si toi tu as déjà resolu , il faut informer , sa va beaucoup aider les gens