Symfony 4 – route : "The requested URL was not found on this server"

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 AppController;

use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;

use SymfonyBundleFrameworkBundleControllerAbstractController;

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,
        ]); 
}

}

?>

Source: Symfony Questions

Was this helpful?

0 / 1

Leave a Reply 0

Your email address will not be published. Required fields are marked *