Answer the question
In order to leave comments, you need to log in
How to organize routing from a database in Symfony 4?
Unfortunately, I can’t find a normal example in the documentation, there is something similar to symfony.com/doc/current/routing/custom_route_loade...
but I feel this option suits me in part.
Let's say the situation is a directory site.
site.ru/{+d}/ - displays all products depending on the pagination
site.ru/{slug}/ - and this can display a category or product page depending on the slug (the problem is that each category or product table has the corresponding slug field - you can of course make one table and get the necessary slug by one-to-one connection, and then everything will be much easier)
i.e. the usual logic is redirected to the desired action controller, depending on what came in the parameter
you can of course cheat, and do all these checks in the Index controller and pull out the necessary logic through the service, or go the easy way (site.ru/category/{slug}/ and site.ru/product/{slug}/)
but you want where -to see how to make the current situation the most "correct" approach?
Answer the question
In order to leave comments, you need to log in
the problem is that each category or product table has a corresponding slug fieldIt is possible to make representation where there will be slug'i from all tables.
and pull out the necessary logic through the serviceIs there forwarding
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question