2
votes

I got a task to update a website. This website uses Symfony2. I try to simulate the website on my localhost.

When I try to get to the index page using a empty direction path (REQUEST_URI) Symfony2 returns No route found for "GET /". The url I try to run is http://localhost/app_dev.php.

And when I use (for example) /booking it doens't work either

What is wrong ?

app/config/routing.yml :

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

app/config/routing_dev.yml :

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_configurator:
    resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
    prefix:   /_configurator

_errors:
    resource: "@TwigBundle/Resources/config/routing/errors.xml"
    prefix:   /_error

_main:
    resource: routing.yml

src/AppBundle/Resources/config/routing.yml :

AppBundle:
    resource: "@AppBundle/Resources/config/routing/routing.yml"
    prefix:   /

AppBundle_booking:
    resource: "@AppBundle/Resources/config/routing/booking.yml"
    prefix:   /bookings

AppBundle_client:
    resource: "@AppBundle/Resources/config/routing/client.yml"
    prefix:   /clients

AppBundle_invoice:
    resource: "@AppBundle/Resources/config/routing/invoice.yml"
    prefix:   /invoices

AppBundle_product:
    resource: "@AppBundle/Resources/config/routing/product.yml"
    prefix:   /products

AppBundle_category:
    resource: "@AppBundle/Resources/config/routing/category.yml"
    prefix:   /categories

AppBundle_contracts:
    resource: "@AppBundle/Resources/config/routing/contract.yml"
    prefix:   /contracts

AppBundle_users:
    resource: "@AppBundle/Resources/config/routing/user.yml"
    prefix: /users

AppBundle_activities:
    resource: "@AppBundle/Resources/config/routing/activity.yml"
    prefix: /activities

AppBundle_services:
    resource: "@AppBundle/Resources/config/routing/service_contract.yml"
    prefix: /services

src/AppBundle/Resources/config/routing/routing.yml :

AppBundle_home:
    pattern: /
    defaults: { _controller: AppBundle:Default:index }

I know there are a lot of other questions that are similar to mine. But when I try to follow the staps of the given answers it still doesn't work. So i hope this will help me.

Thanks in advance.

1
type: annotation, so where are your annotations?D4V1D

1 Answers

2
votes

In your app/config/routing.yml file you defined annotation as your type of routing configuration. However, your are using YML files to configure the routing.

Change your app/config/routing.yml to this:

app:
    resource: "@AppBundle/Resources/config/routing/routing.yml"

And the routing configuration for your bundle should be loaded correctly.