I’m thrilled to announce the immediate availability of FrankenPHP 1.3, just in time for SyliusCon, where I’ll be presenting this new version this afternoon.
First of all, I’d like to thank all the contributors, and in particular Alexander Stecher and Rob Landers, the other two project maintainers, who have done a titanic job.
An incredible amount of work has gone into version 1.3. It contains numerous new features and bug fixes and a major refactoring that has significantly improved FrankenPHP’s performance. Let’s dive into the details!
54% More Efficient Than the Previous Version
Alexander has carried out a major overhaul of the internals of our thread engine and optimized the creation of the $_SERVER
superglobal. The results are breathtaking: according to our benchmarks, when correctly tweaked, version 1.3 can handle 54% more requests with the same hardware than version 1.2.5 (which was already several orders of magnitude more efficient than conventional PHP installations)!
These changes are transparent for end-users of FrankenPHP.
If you’re interested in the changes made to the Go code, consult the “Performance Improvements” section of the changelog.
This isn’t the end of the performance story: new enhancements are on the way, some of which are already ready and will arrive very soon in an upcoming 1.3.1 version.
File Watchers
FrankenPHP 1.3 includes a new feature dedicated to the developer experience: file watchers.
You can now specify a list of files (PHP scripts, templates, config files…) that FrankenPHP will monitor. When one of these files is changed, the worker will be automatically restarted in the background. You no longer need to restart the server manually, you can just press the “refresh” button on your browser (or even better, use Hot Module Reloading if your framework supports it).
To do this, after testing several solutions, we chose to use the brand-new e-dant/watcher
library, which is formidably efficient and works on all platforms. It enables FrankenPHP to monitor directories containing thousands of files without any slowdown. Many thanks to Will for its help in integrating the library.
To enable this feature, just add the new. watch
directive to your worker configuration:
{
frankenphp {
worker {
file /path/to/app/public/worker.php
watch
}
}
}
The default pattern will work with popular frameworks including Laravel, Symfony, and API Platform.
This new feature also has an interesting side-effect for Symfony-based projects, and other projects compiling files or warming caches at build time: this will be done instantly and in the background when a file is modified, further enhancing the developer’s experience.
It’s also possible to configure explicitly the files to watch:
{
frankenphp {
worker {
file /path/to/app/public/worker.php
watch /path/to/app # watches all files in all subdirectories of /path/to/app
watch /path/to/app/*.php # watches files ending in .php in /path/to/app
watch /path/to/app/**/*.php # watches PHP files in /path/to/app and subdirectories
watch /path/to/app/**/*.{php,twig} # watches PHP and Twig files in /path/to/app and subdirectories
}
}
}
Read the new documentation entry about file watchers to learn more about this new feature.
New Prometheus Metrics
Because it is built on top of Caddy, FrankenPHP has provided a Prometheus/OpenMetrics endpoint since day one. Version 1.3 introduces new metrics dedicated to FrankenPHP threads and workers:
frankenphp_busy_threads
: shows current PHP threads processing PHP scripts (including workers waiting for requests)frankenphp_total_threads
: shows the total number of running PHP threadsfrankenphp_[worker]_busy_workers
: shows how many workers are currently processing requestsfrankenphp_[worker]_total_workers
: shows the total amount of workersfrankenphp_[worker]_worker_request_count
: shows the total requests processed by each workerfrankenphp_[worker]_worker_request_time
: shows the total time taken to process requests
Among other use cases, these new metrics can be monitored for autoscaling, as well as to tweak FrankenPHP’s configuration to achieve the best possible performance and efficiency.
Kudos to Rob Landers for this great addition!
Graceful Worker Failures Handling
More explicit errors will be displayed when a worker script is crashing, and FrankenPHP will now try to automatically “heal” the worker when possible. Also contributed by Rob.
Mercure 0.17
FrankenPHP 1.3 includes the brand new version of the Mercure real-time solution, the easiest way to push data in real-time from your PHP apps directly to the browser of your users!
One Line Install Script
Thanks to Pulkit Kathuria, it’s also possible to install FrankenPHP’s static binaries (which include PHP and many extensions) using a single command:
curl https://frankenphp.dev/install.sh | sh
By the way, the static binary now includes ext-parallel, FrankenPHP’s ideal companion for developing PHP scripts that execute functions in parallel:
<?php
$runtime = new \parallel\Runtime();
$future = $runtime->run(function(){
for ($i = 0; $i < 500; $i++)
echo "*";
return "easy";
});
for ($i = 0; $i < 500; $i++) {
echo ".";
}
printf("\nparallel programming is %s\n", $future->value());
Bug Fixes
Last but not least, version 1.3 includes a bunch of fixes, including crashes when using systems or the putenv(
) function. FrankenPHP now also supports FreeBSD.
Consult the full changelog for more details.
Supporting the Project
FrankenPHP is fast becoming the must-have solution for modern PHP application deployment.
Feel free to sponsor me on GitHub and give the project a star to support the project.
My company, Les-Tilleuls.coop, also offers professional support, custom development, and training for FrankenPHP, PHP, and many other technologies. Get in touch with us!
Congrats! Are we good to migrate to 1.3 now?
Amazing! waiting for the 1.3-php8.2-bookworm build!
Thank you!