Supercharging Laravel Performance with Octane and FrankenPHP

Laravel////3 min read

Overview

Laravel Octane 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 SQLite for rapid prototyping.

laravel new my-octane-app

Next, install the Laravel Octane 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 FrankenPHP 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 Pest Stressless 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 FrankenPHP 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 Laravel Octane 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.

Topic DensityMention share of the most discussed topics · 26 mentions across 10 distinct topics
Laravel Octane
27%· products
FrankenPHP
19%· products
Laravel
12%· products
Composer
8%· products
Pest
8%· products
Other topics
27%
End of Article
Source video
Supercharging Laravel Performance with Octane and FrankenPHP

Laravel Octane & FrankenPHP 🧟

Watch

Laravel // 3:20

The official YouTube channel of Laravel, the clean stack for Artisans and agents. We will update you on what's new in the world of Laravel, from the framework to our products Cloud, Forge, and Nightwatch.

3 min read0%
3 min read