Skip to content
Advertisement

Why is my Symfony route is not working?

I made a new Symfony2 bundle and deleted the Acme bundle.

Then I created a new Controller (MainController.php):

JavaScript

And a simple view: (Main/index.html.twig) which only contains a hello. My routing.yml is empty. When I run the whole project I get:

JavaScript

What is wrong here and how to solve it?

Here is my routing debug:

JavaScript

I also cleared the cache with no success.

Here is the routes.yml:

JavaScript

and the routing.yml in MyBlogBundle/Resources/config/routing.yml is empty.

Advertisement

Answer

The way your routes.yml is setup, you are requesting the routing.yml file from your bundle.

If you want to use annotations to manage the routes in your bundle, you have to write the routes.yml the following way:

JavaScript

And your controller needs to include the Route class from the FrameworkExtraBundle:

JavaScript

This assumes you have installed the SensioFrameworkExtraBundle (http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html#installation).

More information on the route annotation: http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement