Quick note : cache your routes in development

Symfony routing is a powerful tool to manage urls and actions mappings. When routes are loaded, many actions are performed :

  • read routing.yml files
  • trigger events so plugins can register new routes
  • compile routes (url routes => regular expression)
  • write cache files

These steps are performed on every requests in ‘dev’ environment, so if routing files do not change, these can be really time consuming. There are other side effects :

  • the debug web toolbar can slow down your browser as the routing log can be very long
  • sfBrowser::call in functional test is also slow down by the loading process.

Solution : set the debug parameter to ‘false’

  • edit your factories.yml
    class: sfPatternRouting
        debug: false
  • of course don’t forget to clear the cache every time the routing.yml is updated …