Je cherche à générer une page
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\HttpFoundation\Request;
class RecipeController extends AbstractController
{
#[Route('/recette/{slug}-{id}', name: 'recipe.show', requirements: ['id' => '\d+', 'slug' => '[a-z0-9-]+'])]
public function index (Request $request): Response
{
dd($request);
}
}
Ce que je veux
Je veux générer une page de la forme /recette/eau-6
Ce que j'obtiens
Not Found
The requested URL was not found on this server.
Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 Server at localhost Port 80.
Pourtant pour la route / cela fonctionne très bien :
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\HttpFoundation\Request;
class HomeController extends AbstractController
{
#[Route('/', name: 'home')]
function index (Request $request): Response {
return new Response('Bonjour ' . $request->query->get('name', 'les gens'));
}
}