What’s new in 3.3
Version 3.3 secures applications running behind a reverse proxy, gives forms full control over their mapping, and hardens the HTTP client.
To upgrade, follow Upgrading from version 3.2 to 3.3.
Secured reverse-proxy prefixes
When a reverse proxy exposes your application under a prefix such as /app, the X-Forwarded-Prefix header is now
accepted only from the proxies you trust. A client can no longer forge it to alter the generated URLs.
{
"berlioz": {
"proxies": {
"trusted": ["10.0.0.1"]
},
"router": {
"X-Forwarded-Prefix": true,
"rewriteRequestUri": true
}
}
}
With rewriteRequestUri, the request URI seen by your controllers includes the prefix, so the URLs derived from it
(pagination, redirections to the current page) are correct.
Custom form mapping
The mapped option of a form element accepts a FormMapping object. You decide how the element reads its value from
the mapped object and writes it back, for example to reach a nested property:
$form->add('display_name', Text::class, [
'mapped' => new FormMapping(
get: fn(object $user): string => $user->profile->name,
set: function (object $user, mixed $value): bool {
$user->profile->name = $value;
return true;
},
),
]);
See Custom mapping.
Safer HTTP client redirections
When a redirection leads to another origin, the HTTP client removes the Authorization, Proxy-Authorization and
Cookie headers you supplied. Declare your own secret headers so that they are removed too:
$client = new Client([
'headers' => [
'Authorization' => 'Bearer example-token',
'X-Api-Key' => 'example-api-key',
],
'redirectSensitiveHeaders' => ['X-Api-Key'],
]);
Cookies are also scoped more strictly: a cookie is only stored for, and sent to, the hosts and paths it belongs to.
See Redirect security.
Other new features
- Debug console: the HTTP section shows the status, the protocol version and the headers of the response. See HTTP response.
- Error logging: server errors caught by the framework are written to the PHP error log, even when debug mode is disabled. See Error logging.
Security fixes
- HTML selector: values interpolated in XPath expressions are encoded, which prevents XPath injection.
- Mailer: MIME boundaries and attachment identifiers use cryptographically secure randomness.
Deprecations
Handling a trusted forwarded prefix without berlioz.router.rewriteRequestUri is deprecated. See
Preparing for version 4.