5
votes

I am having trouble figuring out what is wrong with a singe route in my Symfony2 routing YML file. Every other route is working just fine (and I have a couple dozen already), but this one route refuses to be recognized.

Here is the relevant clip of my YML file:

ProjectMainBundle_util_initUpload:
    pattern:  /util/initUpload
    defaults: { _controller: ProjectMainBundle:Utilities:initUpload }
    requirements:
        _method:  POST

ProjectMainBundle_util_init:
    pattern:  /util/init
    defaults: { _controller: ProjectMainBundle:Utilities:initUtilities }
    requirements:
        _method:  POST

ProjectMainBundle_util_download:
    pattern:  /util/download
    defaults: { _controller: ProjectMainBundle:Utilities:download }
    requirements:
        _method:  GET

The first route, '/util/initUpload', returns a 'No route found for "POST /util/initUpload" error. I've tried placing the block at different places (even moving it above '/util/init'.) The '/' index route is at the end of my routing.yml document, so that shouldn't be the problem. The routes above are the only ones in the format /util/*.

The route serves to handle a form and file upload, but I don't think that matters. I've removed the POST requirement and tested it directly in the browser, and that still gave me the same error.. The camelCase shouldn't be a problem. I have other routes in that format that work just fine...

What else am I missing? Any suggestions on how to debug this? My next step is to scrap the YML file and rewrite using the php format, though I really don't want to do that..

1

1 Answers

20
votes

There is a command to list all of your routes:

For Symfony 2.x -

app/console router:debug

For Symfony 3.x and above -

bin/console debug:router

If you don't see your route in there, first try clearing the cache. If it doesn't help, delete the route definition and retype it again manually — don't copy/paste.

P.S. It has nothing to do with YAML/PHP.