Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f1e6802

Browse filesBrowse files
committed
Merge branch '4.0'
* 4.0: Update dependency_injection.rst Update dependency_injection.rst Fix some misspellings Explained how the URL trailing slash redirection works
2 parents 0bcc079 + 9e930f5 commit f1e6802
Copy full SHA for f1e6802

File tree

Expand file treeCollapse file tree

4 files changed

+29
-4
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+29
-4
lines changed

‎components/validator.rst

Copy file name to clipboardExpand all lines: components/validator.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Usage
2323

2424
The Validator component behavior is based on two concepts:
2525

26-
* Contraints, which define the rules to be validated;
26+
* Constraints, which define the rules to be validated;
2727
* Validators, which are the classes that contain the actual validation logic.
2828

2929
The following example shows how to validate that a string is at least 10

‎create_framework/dependency_injection.rst

Copy file name to clipboardExpand all lines: create_framework/dependency_injection.rst
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ to it::
1010
namespace Simplex;
1111

1212
use Symfony\Component\EventDispatcher\EventDispatcher;
13-
use Symfony\Component\Routing;
1413
use Symfony\Component\HttpFoundation;
14+
use Symfony\Component\HttpFoundation\RequestStack;
1515
use Symfony\Component\HttpKernel;
16+
use Symfony\Component\Routing;
1617

1718
class Framework extends HttpKernel\HttpKernel
1819
{
@@ -195,7 +196,7 @@ Now, here is how you can register a custom listener in the front controller::
195196
// ...
196197
use Simplex\StringResponseListener;
197198

198-
$container->register('listener.string_response', StringResposeListener::class);
199+
$container->register('listener.string_response', StringResponseListener::class);
199200
$container->getDefinition('dispatcher')
200201
->addMethodCall('addSubscriber', array(new Reference('listener.string_response')))
201202
;

‎http_cache.rst

Copy file name to clipboardExpand all lines: http_cache.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ two things:
301301
(e.g. deleting a blog post). Caching them would prevent certain requests from hitting
302302
and mutating your application.
303303

304-
* POST requests are generally considered uncachable, but `they can be cached`_
304+
* POST requests are generally considered uncacheable, but `they can be cached`_
305305
when they include explicit freshness information. However POST caching is not
306306
widely implemented, so you should avoid it if possible.
307307

‎routing.rst

Copy file name to clipboardExpand all lines: routing.rst
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,30 @@ that are special: each adds a unique piece of functionality inside your applicat
493493
``_locale``
494494
Used to set the locale on the request (:ref:`read more <translation-locale-url>`).
495495

496+
Redirecting URLs with Trailing Slashes
497+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
498+
499+
Historically, URLs have followed the UNIX convention of adding trailing slashes
500+
for directories (e.g. ``https://example.com/foo/``) and removing them to refer
501+
to files (``https://example.com/foo``). Although serving different contents for
502+
both URLs is OK, nowadays it's common to treat both URLs as the same URL and
503+
redirect between them.
504+
505+
Symfony follows this logic to redirect between URLs with and without trailing
506+
slashes (but only for ``GET`` and ``HEAD`` requests):
507+
508+
---------- ---------------------------------------- ------------------------------------------
509+
Route path If the requested URL is ``/foo`` If the requested URL is ``/foo/``
510+
---------- ---------------------------------------- ------------------------------------------
511+
``/foo`` It matches (``200`` status response) It doesn't match (``404`` status response)
512+
``/foo/`` It makes a ``301`` redirect to ``/foo/`` It matches (``200`` status response)
513+
---------- ---------------------------------------- ------------------------------------------
514+
515+
In summary, adding a trailing slash in the route path is the best way to ensure
516+
that both URLs work. Read the :doc:`/routing/redirect_trailing_slash` article to
517+
learn how to avoid the ``404`` error when the request URL contains a trailing
518+
slash and the route path does not.
519+
496520
.. index::
497521
single: Routing; Controllers
498522
single: Controller; String naming format

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.