I'm new to Symfony 5 (I started learning it today) and I'm following a course on symfonycasts.com about it, I've done everything as the teacher showed but I still got a 404 error on my controller redirection, here's the code:
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class QuestionController
{
/**
* @Route("/")
*/
public function homepage()
{
return new Response('Homepage');
}
/**
* @return Response
* @Route("/q/{$param}")
*/
public function showQuestions($param)
{
return new Response(sprintf("Hello %s!", $param));
}
}
As you see it's a real simple code, but when I go to http://localhost I have the 'Homepage', if I change the
/**
* @return Response
* @Route("/q/{$param}")
*/
public function showQuestions($param)
{
return new Response(sprintf("Hello %s!", $param));
}
to
/**
* @return Response
* @Route("/q")
*/
public function showQuestions()
{
return new Response("Hello World");
}
I have "Hello World" on http://localhost/q But when I add the /{param} to my annotation like http://localhost/q/Jean I have the Error page telling me that http://localhost/q/Jean does not exist. I have a .htaccess file in my public folder generated by
composer req symfony:apache-pack
and I also tried to clean the php cache and change the development mod with
php bin/console cache:clear --env=prod
but I still have the error. I'm running my symfony app on a XAMPP server Version: XAMPP for Linux 7.4.1-1 On ubuntu 18.04 and Apache 2.4.29