1
votes

I am trying to begin my education of symfony 2 and started with it's tutorial. One of first things I tried was to install symfony 2 and configure it.

When I try to access http://127.0.0.1:8000/, I am getting an incomplete site with the following error:

ERROR - Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /"" at /home/spectator/webprojects/cls/app/cache/dev/classes.php line 2059

Things I have tried so far:

  • clearing cache (php app/console cache:clear --env=prod --no-debug)
  • recursively changing permissions to folder cls (symfony 2 folder) to 775 and even 777 (for diagnostics purposes)
  • adding "/" route to routing.yml and routing_dev.yml
  • reinstalling and
  • re-chmod symfony 2.
5
Fresh installation would most likely means that you're using at least @2.7 version of Symfony. If that's correct your routing should be configured to use annotations by default if you haven't changed that. Open your DefaultController and search for @Route() annotation.Artamiel
Yes, to be more specific it is v2.7.1. DefaultController? I can't find this file anywhere in "cls" folder.spectatorx
You should have a directory named src. This is where your bundles get defined. Inside it you should have your default bundle - as of @2.6 or @2.7 it's called AppBundle. Inside is a folder Controller where you can find your DefaultController.Artamiel
DefaultController.php, yes, i found it now, thx. I will check it.spectatorx
I opened a bug for this a few weeks ago as it's quite misleading for new users following the quick start guide to receive an error as almost the first thing they do: github.com/symfony/symfony-docs/issues/5353BT643

5 Answers

2
votes

Try http://localhost:8000/app/example

Fresh installation has no routes for the root path "/"

0
votes

first you need to set a default route edit the routing.yml app/config/routing.yml

app:
resource: @AppBundle/Controller/  # bundle name / Controller name
type:     annotation  # type of routing or 
# app/config/routing.yml   # file routing 


app: 
resource: @AppBundle/Controller/ 
prefix: / 

you can learn more in http://symfony.com/doc/current/book/routing.html

0
votes

The default installation does not come with a default route for "/".

The example controller only defines a route of

@Route("/app/example", name="homepage")
0
votes

In the past, a fresh Symfony installation also included some simple demo code to learn how does the framework work. A few months ago we decided to change this behavior by the following:

  1. A fresh Symfony installation no longer contains any demo code.
  2. A new "Symfony Demo Application" has been published for people learning the framework (read more about this demo application).

If you use the Symfony Installer, you should do the following:

  1. When learning Symfony, execute the symfony demo command
  2. When creating a new Symfony project, execute the symfony new my_project command
-1
votes

I had the same problem. Just add <?php in the top of the file. Looks like if we don't specify it s