July 5, 2017
I've been working for a time with Symfony Cmf (SfCmf) and I've built some websites with it. Also I've created some extra bundle to implement my own ideas into the SfCmf. The result has been what I called Positibe Project. Positibe Project is a bunch of bundles and libraries that help me and my team work with SfCmf and integrate it with other bundles like Doctrine ORM, Sylius ResourceBundle, Gedmo Doctrine Extension, Lunetics LocaleBundle and much more. Using it we intent to create advance websites with content management systems easily.
One of our goals in our applications is the performance, and some improvements on Symfony Routing have made me think if SfCmf would have some tricks to improve its heavy behavior. We couldn't use Blackfire for many reasons so I checked the whole process by hand, and I found a line where the Dynamic Router checks a regular expression before make the matching process.
So what can we do? Well I defined my scenario and this is what I reached:
1. We use both the Standard Symfony Router and the SfCmf Dynamic Router with the SfCmf Chain Router. If the first does not match then the second is run.
2. We have to decide which one is the first to match.
3. Symfony Router is faster so it usually goes first, the problem is that when it's a content route the Symfony Router is run entirely and after that is when SfCmf Dynamic Router starts its process.
4. Most of the routes of our application are dynamic.
5. The most important part of our application is the frontend where all routes are dynamic except security routes like login and registration.
6. All Symfony routes of our application are grouped with a prefix like /admin or /security, /like /css or /js .
7. Dynamic routes pattern is unpredictable.
So what we could do with this information? Well, first the most important routing for us is the Dynamic Routing so it has to be the first router. That was simple. But we would like to prevent its execution over the symfony routes and all of them are over a prefix and we can use this prefix to exclude the unnecessary process over this routes. We used the options uriFilterRegexp to exclude all fixed routes of my application through a regular expression. This means that the heavy Dynamic Routing is executed first but if the route matches with the expression it will continue to the next router. This process does not decrease the performance of those routes but it increases when a content document is required.
The configuration is very simple and it comes with SfCmf by default. This is my regular expression used on my config file:
# other configs
I hope this helps.
I've been working for a time with Symfony Cmf (SfCmf) and I've built some websites with it. Also I've created some extra bundle to impleme...
Mejorando la experiencia de desarrollar aplicaciones Symfony con Flex
Después de algún tiempo de espera tras anunciar Flex, ya se encuentra disponible y público lo que será el nuevo juguetito de los desarrolladores Symfo...
IMPRESIONES DEL SEGUNDO ENCUENTRO DE DESARROLLADORES HABANA.
Hace solo algunos días que conozco este grupo de entusiastas y emprendedores que se comunican mediante Google Group bajo el nombre de Desarrolladores...