Skip to content

Commit 28cfc36

Browse files
authored
Merge pull request #8117 from kenjis/docs-fix-filters
docs: improve filters
2 parents 0872a21 + 97c3f77 commit 28cfc36

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

user_guide_src/source/incoming/filters.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ You should define as many aliases as you need.
119119
$globals
120120
========
121121

122-
The second section allows you to define any filters that should be applied to every request made by the framework.
122+
The second section allows you to define any filters that should be applied to every valid request made by the framework.
123+
123124
You should take care with how many you use here, since it could have performance implications to have too many
124-
run on every request. Filters can be specified by adding their alias to either the before or after array:
125+
run on every request.
126+
127+
Filters can be specified by adding their alias to either the ``before`` or ``after`` array:
125128

126129
.. literalinclude:: filters/005.php
127130

@@ -130,14 +133,18 @@ Except for a Few URIs
130133

131134
There are times where you want to apply a filter to almost every request, but have a few that should be left alone.
132135
One common example is if you need to exclude a few URI's from the CSRF protection filter to allow requests from
133-
third-party websites to hit one or two specific URI's, while keeping the rest of them protected. To do this, add
136+
third-party websites to hit one or two specific URI's, while keeping the rest of them protected.
137+
138+
To do this, add
134139
an array with the ``except`` key and a URI path (relative to BaseURL) to match as the value alongside the alias:
135140

136141
.. literalinclude:: filters/006.php
137142

138143
Any place you can use a URI path (relative to BaseURL) in the filter settings, you can use a regular expression or, like in this example, use
139144
an asterisk (``*``) for a wildcard that will match all characters after that. In this example, any URI path starting with ``api/``
140-
would be exempted from CSRF protection, but the site's forms would all be protected. If you need to specify multiple
145+
would be exempted from CSRF protection, but the site's forms would all be protected.
146+
147+
If you need to specify multiple
141148
URI paths, you can use an array of URI path patterns:
142149

143150
.. literalinclude:: filters/007.php

user_guide_src/source/incoming/filters/004.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Filters extends BaseConfig
88
{
99
public array $aliases = [
10-
'apiPrep' => [
10+
'api-prep' => [
1111
\App\Filters\Negotiate::class,
1212
\App\Filters\ApiAuth::class,
1313
],

user_guide_src/source/incoming/filters/008.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Filters extends BaseConfig
99
// ...
1010

1111
public array $methods = [
12-
'post' => ['InvalidChars', 'csrf'],
12+
'post' => ['invalidchars', 'csrf'],
1313
'get' => ['csrf'],
1414
];
1515

0 commit comments

Comments
 (0)