this is my first post so i'll try to be understandable.
I am starting with symfony, and there is a problem i can't resolve alone.
This is my controller, and I am working with WAMP. When my Url is "mysite.local", it work normally, and it show me what it should (thanks to the home() function). But when my Url is "mysite.local/hello", i have the following error.
Not Found
The requested URL was not found on this server.
Apache/2.4.41 (Win64) PHP/7.4.0 Server at mysite.local Port 80
I guess this is normal as i didn't created any file named "hello", but it's working in the formation i am following.
Could you help me please ? Thank you
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class HomeController extends AbstractController
{
/**
* @Route("/hello", name="hello")
*/
public function hello()
{
return new Response("Bonjour ...");
}
/**
*@Route("/", name="homepage");
*/
public function home(){
$prenoms = ["Lior" => 17 , "Joseph" => 12, "Anne" => 55];
return $this->render("home.html.twig",
[
'title' => "Bonjour a tous :)",
'age' => "31 ",
'tableau' => $prenoms,
]);
}
}
?>
hello
? Normally in MVC frameworks the route calls the controller's function. Ifmysite.local
works that is because route/
is mapped tohome()
function of the controller. The error message suggests that/hello
does not exist. Please check – Dereism