DEV Community

Cover image for Laravel Octane and FrankenPHP
Roberto B.
Roberto B.

Posted on • Updated on

Laravel Octane and FrankenPHP

In the world of web development, speed of execution and optimal performance are essential. Laravel Octane is the revolutionary solution for optimizing the execution speed of Laravel PHP applications. This article will explore how Laravel Octane, leveraging the powerful application server like FrankenPHP, can accelerate the performance of your application by starting it once and keeping it in memory to respond to requests at supersonic speeds.

The core of Octane's power lies in its application lifecycle approach. Octane starts the application once, keeps it in memory, and responds to requests with supersonic speed. This eliminates the cost of starting the application with each request, significantly improving response times.

To achieve this, Laravel Octane leverages application servers like Swoole, OpenSwoole, Roadrunner, and FrankenPHP. In this article, we will guide you through the installation of a new Laravel application and the configuration of Laravel Octane with FrankenPHP.

Installing Octane with FrankenPHP

To harness the full power of Laravel Octane, integrating it with FrankenPHP is a strategic move. FrankenPHP is an application server designed specifically for PHP, offering advanced features like:

  • support for PHP 8.3;
  • workers mode, that allows your application to be booted once and be kept it in memory;
  • modern compression formats are supported out-of-the-box;
  • native support for HTTPS, HTTP/2 and HTTP/3;
  • automatic HTTPS certificate generation, renewal and revocation;
  • graceful reloads.

This combination provides a robust infrastructure for handling concurrent requests efficiently.

For creating a new application, you can use the composer command:

composer create-project laravel/laravel  octane-frankenphp
Enter fullscreen mode Exit fullscreen mode

Then, you can jump in the new directory:

cd octane-frankenphp
Enter fullscreen mode Exit fullscreen mode

Now you can add Laravel Octane to your application:

composer require laravel/octane
Enter fullscreen mode Exit fullscreen mode

With the command above, you installed the Octane package. The Octane Package also includes the install option that allows you to install the selected application server. In this case, we are going to select FrankenPHP:

php artisan octane:install --server=frankenphp
Enter fullscreen mode Exit fullscreen mode

Installing Octane and FrankenPHP

Now you can start the Server in order to access to your new Laravel application served by FrankenPHP (under the hood FrankenPHP uses Caddy Web Server).

php artisan octane:start
Enter fullscreen mode Exit fullscreen mode

If you want to control the number of workers you can use the workers option:

php artisan octane:start --workers=2
Enter fullscreen mode Exit fullscreen mode

Upon examining the response time, you will notice a significant reduction, particularly after all the workers have responded to their initial requests. It's essential to note that the Application Server dispatches incoming HTTPS requests to active workers using a round-robin algorithm. For instance, if you have two workers, the response time may pleasantly surprise you after the first two requests, with just a few milliseconds. This improvement is attributed to the application being stored in memory and reused for subsequent requests.


Here are some helpful links, if you want to start to play with Octane and FrankenPHP:

Top comments (2)

johndotowl profile image


Since FrankenPHP is using Caddy, does that mean that if I were to setup virtual host / multiple domains , i would need to find a way to modify caddy configuration instead of having nginx

robertobutti profile image
Roberto B.

Hi, I see that FrankenPHP team has released a documentation for deploying in production
In that documentation, they cover the Docker option and if you want to customize the image, there is another official doc

In the future, i would like to explore more the deployment on production, avoiding using docker.