Laravel Octane
Laravel Octane supercharges your application's performance by serving your Laravel application using high-powered application servers. With Spin Pro, Octane is powered by FrankenPHP, providing modern web features and exceptional performance.
What is Laravel Octane?
Laravel Octane keeps your application loaded in memory between requests, dramatically reducing the overhead of bootstrapping your Laravel application on each request. This results in significantly faster response times and improved throughput.
Installation
To install Laravel Octane, you will be prompted to include the Laravel Octane service during Spin installation. Simply select it when prompted.
Laravel Octane in Spin Pro uses FrankenPHP as the application server. We do not use Swoole or RoadRunner.
What Spin does for you
When you install Laravel Octane, Spin automatically:
- Configures your Dockerfile to support FrankenPHP
- Sets up your Docker Compose configuration
- Installs and configures Laravel Octane with FrankenPHP
- Creates a dedicated "Octane" service that runs the following command:
Default Command
php artisan octane:start --server=frankenphp --port=8080
Performance Benefits
With Laravel Octane and FrankenPHP, your application gains:
- Memory Persistence: Your application stays loaded in memory between requests
- HTTP/2 & HTTP/3 Support: Modern web protocols for faster data transfer
- Automatic HTTPS: Built-in TLS certificate management
- Worker Mode: Handle multiple requests with a single application boot
- Reduced Latency: Eliminate bootstrapping overhead on each request
Usage
Once you run spin up in your development environment, your Laravel application will be served by Octane with FrankenPHP. You can access your application at the standard URL: http://laravel.dev.test
Your application will feel noticeably faster, especially for complex applications with many service providers, middleware, or database queries during bootstrapping.
Important Considerations
When using Laravel Octane, keep these points in mind:
- Memory Leaks: Be cautious of memory leaks in long-running processes
- Global State: Avoid storing state in global variables between requests
- Singletons: Be aware that singletons persist between requests
- File Changes: In development, the server automatically restarts when files change
Always test your application thoroughly with Octane, as the persistent nature can expose issues that don't appear in traditional request/response cycles.