diff --git a/book/forms.rst b/book/forms.rst
index 7ee7bff700d..504cc8a7ed6 100644
--- a/book/forms.rst
+++ b/book/forms.rst
@@ -1036,7 +1036,9 @@ to the ``form()`` or the ``form_start()`` helper:
start($form, array(
- 'action' => $view['router']->generate('target_route'),
+ // The path() method was introduced in Symfony 2.8. Prior to 2.8,
+ // you had to use generate().
+ 'action' => $view['router']->path('target_route'),
'method' => 'GET',
)) ?>
diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst
index d243b390434..5420a31ea1b 100644
--- a/book/from_flat_php_to_symfony2.rst
+++ b/book/from_flat_php_to_symfony2.rst
@@ -598,7 +598,7 @@ database and the Templating component to render a template and return a
-
- path(
'blog_show',
array('id' => $post->getId())
) ?>">
diff --git a/book/http_cache.rst b/book/http_cache.rst
index bf91ff2345d..e01baff8c6d 100644
--- a/book/http_cache.rst
+++ b/book/http_cache.rst
@@ -1087,23 +1087,22 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags:
- // you can use a controller reference
- use Symfony\Component\HttpKernel\Controller\ControllerReference;
+
render(
- new ControllerReference(
+ new \Symfony\Component\HttpKernel\Controller\ControllerReference(
'AppBundle:News:latest',
array('maxPerPage' => 5)
),
array('strategy' => 'esi')
) ?>
- // ... or a URL
- use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+
render(
- $view['router']->generate(
+ // The url() method was introduced in Symfony 2.8. Prior to 2.8,
+ // you had to use generate($name, $parameters, UrlGeneratorInterface::ABSOLUTE_URL)
+ $view['router']->url(
'latest_news',
array('maxPerPage' => 5),
- UrlGeneratorInterface::ABSOLUTE_URL
),
array('strategy' => 'esi'),
) ?>
diff --git a/book/routing.rst b/book/routing.rst
index ed0b4bf809c..b57ad003e2e 100644
--- a/book/routing.rst
+++ b/book/routing.rst
@@ -1531,12 +1531,16 @@ a template helper function:
.. code-block:: html+php
- path('blog_show', array(
'slug' => 'my-blog-post',
)) ?>">
Read this blog post.
+.. versionadded:: 2.8
+ The ``path()`` PHP templating helper was introduced in Symfony 2.8. Prior
+ to 2.8, you had to use the ``generate()`` helper method.
+
.. index::
single: Routing; Absolute URLs
@@ -1550,9 +1554,8 @@ method::
$this->generateUrl('blog_show', array('slug' => 'my-blog-post'), true);
// http://www.example.com/blog/my-blog-post
-From a template, in Twig, simply use the ``url()`` function (which generates an absolute URL)
-rather than the ``path()`` function (which generates a relative URL). In PHP, pass ``true``
-to ``generate()``:
+From a template, simply use the ``url()`` function (which generates an absolute
+URL) rather than the ``path()`` function (which generates a relative URL):
.. configuration-block::
@@ -1564,16 +1567,18 @@ to ``generate()``:
.. code-block:: html+php
-
-
- url('blog_show', array(
'slug' => 'my-blog-post',
- ), UrlGeneratorInterface::ABSOLUTE_URL) ?>">
+ )) ?>">
Read this blog post.
+.. versionadded:: 2.8
+ The ``url()`` PHP templating helper was introduced in Symfony 2.8. Prior
+ to 2.8, you had to use the ``generate()`` helper method with
+ ``Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL``
+ passed as third argument.
+
.. note::
The host that's used when generating an absolute URL is automatically
diff --git a/book/templating.rst b/book/templating.rst
index 4c1de72f752..8f558e5cf40 100644
--- a/book/templating.rst
+++ b/book/templating.rst
@@ -709,8 +709,11 @@ tags:
array('renderer' => 'hinclude')
) ?>
+
render(
- $view['router']->generate('...'),
+ $view['router']->url('...'),
array('renderer' => 'hinclude')
) ?>
@@ -918,7 +921,9 @@ To link to the page, just use the ``path`` Twig function and refer to the route:
.. code-block:: html+php
- Home
+
+ Home
As expected, this will generate the URL ``/``. Now, for a more complicated
route:
@@ -997,7 +1002,9 @@ correctly:
- path('article_show', array(
'slug' => $article->getSlug(),
)) ?>">
getTitle() ?>
@@ -1006,26 +1013,26 @@ correctly:
.. tip::
- You can also generate an absolute URL by using the ``url`` Twig function:
+ You can also generate an absolute URL by using the ``url`` function:
- .. code-block:: html+twig
+ .. configuration-block::
- Home
+ .. code-block:: html+twig
- The same can be done in PHP templates by passing a third argument to
- the ``generate()`` method:
+ Home
- .. code-block:: html+php
+ .. code-block:: html+php
-
+ Home
- Home
+ .. versionadded:: 2.8
+ The ``url()`` PHP templating helper was introduced in Symfony 2.8. Prior
+ to 2.8, you had to use the ``generate()`` helper method with
+ ``Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL``
+ passed as third argument.
.. index::
single: Templating; Linking to assets
@@ -1696,7 +1703,9 @@ key in the parameter hash:
.. code-block:: html+php
- path('article_show', array(
'id' => 123,
'_format' => 'pdf',
)) ?>">
diff --git a/cookbook/security/csrf_in_login_form.rst b/cookbook/security/csrf_in_login_form.rst
index b7649aa92f7..5853bbec647 100644
--- a/cookbook/security/csrf_in_login_form.rst
+++ b/cookbook/security/csrf_in_login_form.rst
@@ -107,7 +107,9 @@ using the login form:
-