File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,28 @@ are also supported::
316
316
$quality = $accept->get('text/xml')->getQuality(); // $quality = 0.8
317
317
$quality = $accept->get('application/xml')->getQuality(); // $quality = 0.3
318
318
319
+ Anonymizing IP Addresses
320
+ ~~~~~~~~~~~~~~~~~~~~~~~~
321
+
322
+ .. versionadded :: 4.4
323
+
324
+ The ``anonymize() `` method was introduced in Symfony 4.4.
325
+
326
+ An increasingly common need for applications to comply with user protection
327
+ regulations is to anonymize IP addresses before logging and storing them for
328
+ analysis purposes. Use the ``anonymize() `` method from the
329
+ :class: `Symfony\\ Component\\ HttpFoundation\\ IpUtils ` to do that::
330
+
331
+ use Symfony\Component\HttpFoundation\IpUtils;
332
+
333
+ $ipv4 = '123.234.235.236';
334
+ $anonymousIpv4 = IPUtils::anonymize($ipv4);
335
+ // $anonymousIpv4 = '123.234.235.0'
336
+
337
+ $ipv6 = '2a01:198:603:10:396e:4789:8e99:890f';
338
+ $anonymousIpv6 = IPUtils::anonymize($ipv6);
339
+ // $anonymousIpv6 = '2a01:198:603:10::'
340
+
319
341
Accessing other Data
320
342
~~~~~~~~~~~~~~~~~~~~
321
343
You can’t perform that action at this time.
0 commit comments