@@ -32,13 +32,42 @@ If you expect a GET request, you use the ``get()`` method:
3232.. literalinclude :: routing/001.php
3333
3434A route takes the URI path (``/ ``) on the left, and maps it to the controller and method (``Home::index ``) on the right,
35- along with any parameters that should be passed to the controller. The controller and method should
35+ along with any parameters that should be passed to the controller.
36+
37+ The controller and method should
3638be listed in the same way that you would use a static method, by separating the class
37- and its method with a double-colon, like ``Users::list ``. If that method requires parameters to be
39+ and its method with a double-colon, like ``Users::list ``.
40+
41+ If that method requires parameters to be
3842passed to it, then they would be listed after the method name, separated by forward-slashes:
3943
4044.. literalinclude :: routing/002.php
4145
46+ Examples
47+ ========
48+
49+ Here are a few basic routing examples.
50+
51+ A URL containing the word **journals ** in the first segment will be mapped to the ``\App\Controllers\Blogs `` class,
52+ and the default method, which is usually ``index() ``:
53+
54+ .. literalinclude :: routing/006.php
55+
56+ A URL containing the segments **blog/joe ** will be mapped to the ``\App\Controllers\Blogs `` class and the ``users() `` method.
57+ The ID will be set to ``34 ``:
58+
59+ .. literalinclude :: routing/007.php
60+
61+ A URL with **product ** as the first segment, and anything in the second will be mapped to the ``\App\Controllers\Catalog `` class
62+ and the ``productLookup() `` method:
63+
64+ .. literalinclude :: routing/008.php
65+
66+ A URL with **product ** as the first segment, and a number in the second will be mapped to the ``\App\Controllers\Catalog `` class
67+ and the ``productLookupByID() `` method passing in the match as a variable to the method:
68+
69+ .. literalinclude :: routing/009.php
70+
4271HTTP verbs
4372==========
4473
@@ -99,31 +128,6 @@ Placeholders Description
99128.. note :: ``{locale}`` cannot be used as a placeholder or other part of the route, as it is reserved for use
100129 in :doc: `localization </outgoing/localization >`.
101130
102- Examples
103- ========
104-
105- Here are a few basic routing examples.
106-
107- A URL containing the word **journals ** in the first segment will be mapped to the ``\App\Controllers\Blogs `` class,
108- and the default method, which is usually ``index() ``:
109-
110- .. literalinclude :: routing/006.php
111-
112- A URL containing the segments **blog/joe ** will be mapped to the ``\App\Controllers\Blogs `` class and the ``users() `` method.
113- The ID will be set to ``34 ``:
114-
115- .. literalinclude :: routing/007.php
116-
117- A URL with **product ** as the first segment, and anything in the second will be mapped to the ``\App\Controllers\Catalog `` class
118- and the ``productLookup() `` method:
119-
120- .. literalinclude :: routing/008.php
121-
122- A URL with **product ** as the first segment, and a number in the second will be mapped to the ``\App\Controllers\Catalog `` class
123- and the ``productLookupByID() `` method passing in the match as a variable to the method:
124-
125- .. literalinclude :: routing/009.php
126-
127131Note that a single ``(:any) `` will match multiple segments in the URL if present. For example the route:
128132
129133.. literalinclude :: routing/010.php
0 commit comments