0
votes

I would like to develop a CMS using Symfony 2 that has 2 bundles: one for pages and one for galleries (in the future there will be more bundles). All pages and galleries will be stored in database and they will be dynamically changed. I have two question about routing in this situation.

  1. What is a good pattern for adding a dynamical routing (using database) in symfony2? Is it a good practice to develop a central controller (dispatcher) that will redirect user to the correct bundle?
  2. I found in documentation that there is "CMF Dynamic Routing" http://symfony.com/doc/master/cmf/bundles/routing/dynamic.html is it possible to use it without any other part of CMF?

Regards,

1
Why do you need something dynamic? You can format the URL as you want, with records ids or slug: symfony.com/doc/current/book/routing.html#routing-in-actionA.L
Yes, but they look almost the same: @Route("/{slug}") for page and @Route("/{slug}") for galleryMdt
I think that you should keep it simple and add a suffix to differentiate the 2 types of URLs. Or you can add a central table to store URLs and link it to the other entities, it will require less database access that having to search URL in each entity table.A.L
for example @Route("/p-{slug}") for page and @Route("/g-{slug}") for gallery I'm not sure, but I think it will have a negative influence on SEOMdt

1 Answers

1
votes

regarding point 2: correct, you can use the CMF Routing component independently and its a good way to go.

You just need to write a ContentAwareGenerator to generate Url's for you and a RouteProvider to create Route objects matching your urls.