musicman
musicman

Reputation: 525

Symfony3: Routing & Cache

I'm planning my first project with the actual version of Symfony 3.0. So this won't be my last question :)

What I wonder most about at the moment are routes. In the symfony book the default way to realize routes is by using annotations in the controller classes. Does this mean every single time someone hits my URL all the classes are parsed to find the most matching route? Wouldn't be this a real performance issue? Or is there a built-in cache?

Upvotes: 2

Views: 1356

Answers (2)

Matteo
Matteo

Reputation: 39390

I suggest to take a look at the talk

Symfony Routing Under the hood - David Buchmann

That do a great overview to the Symfony Routing component.

Routing is compiled in php code, that is cached in prod environment

Main point of optimization is about:

  • Compile routes to PHP
  • Dump cached matcher, single class
  • Group similar routes
  • Prefer strpos, use regex only when needed
  • Possesive quantifiers in regex

Hope this help

Upvotes: 2

Mantas
Mantas

Reputation: 4296

Annotations are compiled to PHP code an cached in this way (check documentation), but url is matched to rules in the beginning of every request.

Upvotes: 2

Related Questions