What’s new in 3.2
Version 3.2 adds cache drivers for multi-server deployments, database migrations, a metrics endpoint for queues, and closes several security holes of the debug tools.
Cache drivers
Two cache drivers are added. The Redis driver shares the cache between servers, and the fallback driver keeps the application working when a driver fails:
$cache = new FallbackCacheDriver([
new RedisCacheDriver($redis, 'my-project'),
new FileCacheDriver('/var/cache'),
new MemoryCacheDriver(),
]);
A factory builds the driver from an array of options, a JSON file or environment variables.
See Cache.
Database migrations
The Hector ORM package runs database migrations from the command line:
# Apply all pending migrations
$ vendor/bin/berlioz hector:migrate
# Roll back migrations
$ vendor/bin/berlioz hector:migrate:down
# Show the status of migrations (applied / pending)
$ vendor/bin/berlioz hector:migrate:status
See Database migrations.
Queue metrics over HTTP
The metrics of the queue:size command can be served over HTTP, so that a Prometheus server scrapes them directly.
The endpoint is disabled by default:
{
"berlioz": {
"queues": {
"metrics": {
"enable": true,
"path": "/metrics/queues",
"ip": ["127.0.0.1", "10.0.0.0/8"]
}
}
}
}
See HTTP endpoint.
Debug tools
- Snapshot retention: old debug snapshots are deleted automatically, according to a maximum age and a maximum
number of files. The
berlioz:debug-clearcommand deletes them on demand. See Snapshot retention. - SQL queries: the debug console highlights slow queries and detects duplicate queries. See Debug console.
- Cache: the debug console clears the internal cache, OPcache and the cache directories.
Other new features
- HTTP client: the default adapter,
AutoAdapter, uses cURL when the extension is installed and PHP streams otherwise. See AutoAdapter.
Security changes
These changes can require an action when you upgrade:
- Debug IP restriction: the
X-Forwarded-Forheader is no longer trusted by default. Behind a reverse proxy, declare its address inberlioz.proxies.trusted. See Client IP resolution behind a proxy. - Debug console: every page of the console is restricted to debug mode and to the allowed IPs. Other requests get a 404 error.
berlioz:systemjob handler: it is no longer registered by default, and it runs commands without a shell. Seeberlioz:system.- HTTP messages and mails: line breaks are rejected in header names and values, to prevent header injection.
- Cache files: cache directories and files are created with restrictive permissions.