Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony3 - No route found for "GET/home"

Tags:

php

symfony

I am following this tutorial to set up my first page in a Symfony 3 project: Joyful Development with Symfony 3 Tutorial

I created a HomeController file in /src/AppBundle/Controller/. The contents of this file are:

 <?php

 namespace AppBundle\Controller;

 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Symfony\Component\HttpFoundation\Response;

 class HomeController {

  /**
   * @Route("/home")
   */

  public function showAction() {
      return new Response('Testing!');
  }
 }

I am simply trying to get the text: "Testing!" from the showAction() function above to display. However, my page has an error: No route found for "GET /home"

Is there something wrong with my setup above? Sorry if this is a simple question, this is my first time working with Symfony and I am lost!

Symfony Error Message

like image 639
Liz Avatar asked Jan 09 '17 23:01

Liz


1 Answers

If you are testing on localhost, you can go to your project directory and use the built-in web server to test your project:

php bin/console server:start

and to stop it:

php bin/console server:stop

To debug routes, enter:

php bin/console debug:router

That should display all your routes. Once this works, it's a matter of getting your Nginx working.

You can also specify a different IP address for the built-in server. See the documentation: http://symfony.com/doc/current/setup/built_in_web_server.html#starting-the-web-server

like image 190
Alvin Bunk Avatar answered Sep 28 '22 05:09

Alvin Bunk