Kamran Ahmed
Kamran Ahmed

Reputation: 12428

Symfony2 No route found for "GET /": Method Not Allowed (Allow: POST)

I have two routes defined in in a bundle inside routing.yml and that are:

dm_dashboard:
    pattern:   /
    defaults:  { _controller: DigitalManagerERPBundle:Default:login }
    methods:  [GET]
dm_dashboard:
    pattern:  /
    defaults: { _controller: DigitalManagerERPBundle:Default:processLogin }
    methods:  [POST]

i.e. chose the first route for GET method and chose the second for the POST method. But when I try to get that to path, I am getting this error

No route found for "GET /": Method Not Allowed (Allow: POST)

and none of the routes get executed. Can anyone please tell me what I'm doing wrong here? Why none of the routes executes?

P.S Newbie here

Upvotes: 4

Views: 19204

Answers (1)

jmoreno
jmoreno

Reputation: 612

They have both the same name

Try this:

dm_dashboard_login:
    pattern:   /
    defaults:  { _controller: DigitalManagerERPBundle:Default:login }
    methods:  [GET]
dm_dashboard_process:
    pattern:  /
    defaults: { _controller: DigitalManagerERPBundle:Default:processLogin }
    methods:  [POST]

Upvotes: 9

Related Questions