Skip to content

Commit 8e36327

Browse files
committed
feature #6021 mention routing from the database (dbu)
This PR was merged into the 2.3 branch. Discussion ---------- mention routing from the database | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes | Applies to | 2.3+ | Fixed tickets | #2186, relates to #5709 if we merge #6020, we might want to put this as subsection of the extending_routing section Commits ------- c458431 mention routing from the database
2 parents 8a93aa4 + c458431 commit 8e36327

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

cookbook/map.rst.inc

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
* :doc:`/cookbook/routing/custom_route_loader`
151151
* :doc:`/cookbook/routing/redirect_trailing_slash`
152152
* :doc:`/cookbook/routing/extra_information`
153+
* :doc:`/cookbook/routing/routing_from_database`
153154

154155
* :doc:`Security Authentication (Identifying/Logging in the User) </cookbook/security/index>`
155156

cookbook/routing/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Routing
1212
custom_route_loader
1313
redirect_trailing_slash
1414
extra_information
15+
routing_from_database
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. index::
2+
single: Routing; Extra Information
3+
4+
Looking up Routes from a Database: Symfony CMF DynamicRouter
5+
============================================================
6+
7+
The core Symfony Routing System is excellent at handling complex sets
8+
of routes. A highly optimized routing cache is dumped during
9+
deployments.
10+
11+
However, when working with large amounts of data that each need a nice
12+
readable URL (e.g. for search engine optimization purposes), the routing
13+
can get slowed down. Additionally, if routes need to be edited by users,
14+
the route cache would need to be rebuilt frequently.
15+
16+
For these cases, the ``DynamicRouter`` offers an alternative approach:
17+
18+
* Routes are stored in a database;
19+
* There is a database index on the path field, the lookup scales to huge
20+
numbers of different routes;
21+
* Writes only affect the index of the database, which is very efficient.
22+
23+
When all routes are known during deploy time and the number is not too
24+
high, using a :doc:`custom route loader <custom_route_loader>` is the
25+
preferred way to add more routes. When working with just one type of
26+
objects, a slug parameter on the object and the ``@ParamConverter``
27+
annotation work fine (see FrameworkExtraBundle_) .
28+
29+
The ``DynamicRouter`` is useful when you need ``Route`` objects with
30+
the full feature set of Symfony. Each route can define a specific
31+
controller so you can decouple the URL structure from your application
32+
logic.
33+
34+
The DynamicRouter comes with built-in support for Doctrine ORM and Doctrine
35+
PHPCR-ODM but offers the ``ContentRepositoryInterface`` to write a custom
36+
loader, e.g. for another database type or a REST API or anything else.
37+
38+
The DynamicRouter is explained in the `Symfony CMF documentation`_.
39+
40+
.. _FrameworkExtraBundle: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
41+
.. _`Symfony CMF documentation`: http://symfony.com/doc/master/cmf/book/routing.html

0 commit comments

Comments
 (0)