@@ -18,7 +18,7 @@ areas of your application. By the end of this chapter, you'll be able to:
18
18
19
19
* Create complex routes that map to controllers
20
20
* Generate URLs inside templates and controllers
21
- * Load routing resources from bundles (or anywhere else)
21
+ * Load routing resources from bundles (or anywhere else)
22
22
* Debug your routes
23
23
24
24
.. index ::
@@ -90,7 +90,7 @@ pattern that points to a specific PHP class and method:
90
90
{
91
91
// use the $slug variable to query the database
92
92
$blog = ...;
93
-
93
+
94
94
return $this->render('AcmeBlogBundle:Blog:show.html.twig', array(
95
95
'blog' => $blog,
96
96
));
@@ -103,7 +103,7 @@ will be executed and the ``$slug`` variable will be equal to ``my-post``.
103
103
104
104
This is the goal of the Symfony2 router: to map the URL of a request to a
105
105
controller. Along the way, you'll learn all sorts of tricks that make mapping
106
- even the most complex URLs easy.
106
+ even the most complex URLs easy.
107
107
108
108
.. index ::
109
109
single: Routing; Under the hood
@@ -821,7 +821,7 @@ The controller might look like this:
821
821
namespace Acme\BlogBundle\Controller;
822
822
823
823
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
824
-
824
+
825
825
class BlogController extends Controller
826
826
{
827
827
public function showAction($slug)
@@ -1015,6 +1015,12 @@ instead of simply ``/hello/{name}``:
1015
1015
The string ``/admin `` will now be prepended to the pattern of each route
1016
1016
loaded from the new routing resource.
1017
1017
1018
+ .. tip ::
1019
+
1020
+ You can also define routes using annotations. See the
1021
+ :doc: `FrameworkExtraBundle documentation<bundles/SensioFrameworkExtraBundle/annotations/routing> `
1022
+ to see how to.
1023
+
1018
1024
.. index ::
1019
1025
single: Routing; Debugging
1020
1026
@@ -1091,9 +1097,9 @@ In an upcoming section, you'll learn how to generate URLs from inside templates.
1091
1097
If the frontend of your application uses AJAX requests, you might want
1092
1098
to be able to generate URLs in JavaScript based on your routing configuration.
1093
1099
By using the `FOSJsRoutingBundle `_, you can do exactly that:
1094
-
1100
+
1095
1101
.. code-block :: javascript
1096
-
1102
+
1097
1103
var url = Routing .generate (' blog_show' , { " slug" : ' my-blog-post' });
1098
1104
1099
1105
For more information, see the documentation for that bundle.
@@ -1120,9 +1126,9 @@ method:
1120
1126
on server information supplied by PHP. When generating absolute URLs for
1121
1127
scripts run from the command line, you'll need to manually set the desired
1122
1128
host on the ``RequestContext `` object:
1123
-
1129
+
1124
1130
.. code-block :: php
1125
-
1131
+
1126
1132
$router->getContext()->setHost('www.example.com');
1127
1133
1128
1134
.. index ::
0 commit comments