Supercharging Laravel Performance with Octane and FrankenPHP

Overview

boosts your application performance by serving requests using high-performance application servers. By keeping your application in memory, it eliminates the overhead of booting the framework on every request. The newest addition to the
Laravel Octane
ecosystem is
FrankenPHP
, a modern server written in
Go
that offers exceptional speed and features like automatic HTTPS. This integration represents a massive leap forward for developers seeking sub-millisecond response times.

Prerequisites

Before moving forward, ensure you have the following in your environment:

  • PHP
    8.2 or higher
  • Composer
    for package management
  • Basic familiarity with the
    Laravel
    directory structure
  • A terminal environment capable of running binary files

Key Libraries & Tools

  • Laravel Octane
    : The core package that integrates high-performance servers with
    Laravel
    .
  • FrankenPHP
    : A modern
    PHP
    app server built on top of the
    Caddy
    web server.
  • Pest
    : A testing framework focused on simplicity and speed.
  • Pest Stressless
    : A plugin for
    Pest
    used to perform stress testing and performance benchmarking.

Code Walkthrough

First, initialize a new project. We skip the starter kits to keep the setup lean and choose

for rapid prototyping.

laravel new my-octane-app

Next, install the

package via
Composer
. This provides the necessary scaffolding to bridge
Laravel
and
FrankenPHP
.

composer require laravel/octane

Now, run the installation command. When prompted for the server type, select frankenphp. The installer automatically downloads the necessary

binary for your architecture.

php artisan octane:install

Finally, fire up the server. You will receive a local URL where your application is now running in a persistent state.

php artisan octane:start

Syntax Notes

When using

to verify performance, the syntax is remarkably clean. Running ./vendor/bin/pest stress http://localhost:8000 --concurrency=5 tells the plugin to hit the endpoint with five simultaneous users. Note how the CLI output provides real-time feedback on request duration and successful hits.

Practical Examples

In a standard setup, a single request might take 30-50ms to boot the framework. With

and
Laravel Octane
, benchmark results show response times as low as 0.93ms. This is ideal for high-traffic APIs or real-time dashboards where latency must be kept to an absolute minimum.

Tips & Gotchas

Since

keeps your app in memory, global variables or static properties do not reset between requests. Always use dependency injection or the Octane::forget method to clear state. If you make code changes, remember that
Laravel Octane
needs to restart to pick them up, or you can use the --watch flag during development.

3 min read