A brand new way to serve a Laravel PHP Applications

Jhoan B. Henriche
3 min readApr 1, 2024

Back in 2021, Laravel team announced the release of Laravel Octane — a first-party package for Laravel that supercharges Laravel application’s performance by executing your code using high-powered application servers like Swoole and RoadRunner.

Laravel team also shipped built-in support for Octane in Forge and Vapor, ensuring an even smoother Octane onboarding experience.

Since Laravel 11 is “still in the kitchen” and our project is still taking form, i’d highly suggest start using Octane with RoadRunner instead of the classic apache or nginx configuration. We could definitely start with nginx but this might not be the best solution know already that our API will make a lot of calculations using microservices architecture. FrankenPHP is the ideal choice and maybe the standard in a nutshell but we will talk about frankenPHP after some considerations.

# Concurrency 1 for 5 seconds...
./vendor/bin/pest stress http://127.0.0.1:8000
Swoole Medium Request Duration ........... 4.94 ms
RoadRunner Medium Request Duration ....... 2.61 ms
FrankenPHP Medium Request Duration ....... 0.88 ms
# Concurrency 8 for 5 seconds...
./vendor/bin/pest stress http://127.0.0.1:8000 --concurrency=8
Swoole Medium Request Duration ........... 5.39 ms
RoadRunner Medium Request Duration ....... 4.00 ms
FrankenPHP Medium Request Duration ....... 1.59 ms

The winner is clear RoadRunner, but why not FrankenPHP? FrankenPHP is still in development and community is still waiting it’s release.

FrankenPHP is a modern PHP server, developed by Kévin Dunglas, that supports modern web features such as early hints, automatic SSL certificate management, and Zstandard compression. Check out the FrankenPHP website to learn more about what it has to offer: frankenphp.dev.

FrankenPHP is written in GO

FrankenPHP also ships with built-in support for Mercure, a modern and convenient replacement for WebSockets, which we are hoping to integrate with Laravel’s broadcasting capabilities in the future.

We should start running RoadRunner as long as possible but knowing in mind that FrankenPHP will be present in the Official Laravel documentation soon, but octane make this switch possible.

Please refer to Nuno Maduro’s post from the Laravel Team and Creator of Pest to get more information.

If you wanna take a look to some real time comparison between the previous servers please refer to the following medium post by Emre Çalışkan where you can see charts like the one bellow:

You can also test it by yourself using this fork : https://github.com/jhoanborges/laravel-benchmark .

--

--

Jhoan B. Henriche

I like to code and I can not lie. IT Manager at Senter Logistics.