Configure Laravel Octane
Laravel Octane is a performance-boosting package designed to enhance the speed, efficiency, and scalability of Laravel applications, including Bagisto.
What You'll Learn
- Install Laravel Octane in your Bagisto application
- Configure Octane for optimal performance
- Run and manage the Octane server
Benefits for Bagisto
- Performance: Drives remarkable improvements in page load times, ensuring a seamless and responsive shopping experience
- Scalability: Provides the scalability required to accommodate the growth of e-commerce businesses
- Foundation: Forms the foundation for optimizing Bagisto's performance and meeting the demands of modern e-commerce
Prerequisites
Before installing Laravel Octane, ensure your system meets the basic requirements. The specific requirements may vary depending on which application server you choose (Swoole, FrankenPHP, or RoadRunner).
Requirements
- PHP 8.2
- Existing Bagisto installation
Server-Specific Requirements
Choose one of the following server options:
For Swoole Server
- Swoole PHP extension must be installed on your system
Verify Swoole is installed:
php --ri swooleFor FrankenPHP Server
- No additional PHP extensions required
- FrankenPHP binary will be automatically downloaded during installation
- Supports automatic HTTPS, HTTP/2, and HTTP/3 out of the box
Verify FrankenPHP (after installation):
./frankenphp versionFor RoadRunner Server
- No additional PHP extensions required
- RoadRunner binary will be automatically downloaded during installation
- Built with Go for high performance and scalability
- Supports HTTP, gRPC, and background job processing
Verify RoadRunner (after installation):
./rr versionInstallation
Laravel Octane installation for Bagisto involves installing the Octane package via Composer and then configuring it to use Swoole, FrankenPHP, or RoadRunner as the application server. All three options will enhance your Bagisto application's performance significantly.
Install Laravel Octane
Navigate to your Bagisto directory and install Octane:
# Navigate to your Bagisto project
cd /path/to/your/bagisto
# Install Laravel Octane
composer require laravel/octane
# Install Octane (will prompt for server selection)
php artisan octane:installChoose Your Server
Server Selection
After running php artisan octane:install, the terminal will prompt you to select a server from these options:
- Swoole - High-performance async PHP server with advanced features like concurrent tasks
- FrankenPHP - Modern PHP server with native HTTP/2, HTTP/3, and automatic HTTPS
- RoadRunner - Go-based application server with excellent performance and plugin ecosystem
All three servers are excellent choices for Bagisto. This guide covers all options.
Direct Installation Options
If you prefer to skip the interactive prompt:
# Install with Swoole
php artisan octane:install --server=swoole
# Install with FrankenPHP
php artisan octane:install --server=frankenphp
# Install with RoadRunner
php artisan octane:install --server=roadrunnerRoadRunner Additional Setup
For RoadRunner, you may also need to install additional packages:
# Install RoadRunner CLI and HTTP packages (optional)
composer require spiral/roadrunner-http spiral/roadrunner-cliEnvironment Configuration
After completing the installation, the appropriate server configuration will be automatically added to your .env file based on your selection.
For Swoole Server
OCTANE_SERVER=swooleFor FrankenPHP Server
OCTANE_SERVER=frankenphpFor RoadRunner Server
OCTANE_SERVER=roadrunnerRunning Octane
Basic Usage
Start Octane server (uses configured server from .env):
php artisan octane:startCommon Issues
While Laravel Octane with Swoole, FrankenPHP, and RoadRunner is generally stable, you might encounter some common issues during setup or operation. Here are the most frequent problems and their solutions to help you troubleshoot your Bagisto Octane installation.
General Troubleshooting
| Problem | Solution |
|---|---|
| Port already in use | Change the port or stop conflicting services |
| Memory leaks | Reduce the max request by specifying in the octane command |
| Slow startup | Ensure database connections are properly configured |
| Worker crashes | Check PHP error logs and reduce worker count if needed |
| Swoole extension not found | Install via pecl install swoole or use package manager |
| FrankenPHP binary not found | Re-run php artisan octane:install --server=frankenphp |
| RoadRunner binary not found | Re-run php artisan octane:install --server=roadrunner |
Quick Start Guide
Install Laravel Octane:
bashcomposer require laravel/octaneChoose and setup your server:
bash# For Swoole php artisan octane:install --server=swoole # For FrankenPHP php artisan octane:install --server=frankenphp # For RoadRunner php artisan octane:install --server=roadrunnerConfigure your
.envfile:- For Swoole:
OCTANE_SERVER=swoole - For FrankenPHP:
OCTANE_SERVER=frankenphp - For RoadRunner:
OCTANE_SERVER=roadrunner
- For Swoole:
Start the server:
bashphp artisan octane:startAccess your application:
- Visit
http://localhost:8000
- Visit
