Laravel Octane with Swoole
Laravel Octane with Swoole
Swoole is a high-performance PHP extension that provides asynchronous, parallel, and coroutine capabilities. When combined with Laravel Octane, it delivers exceptional performance for high-traffic applications.
What is Swoole?
Swoole is a PHP extension that offers:
- Asynchronous I/O operations
- Coroutine support for concurrent processing
- Built-in connection pooling
- Task workers for background processing
- Excellent performance under high load
Setting up Octane with Swoole
Follow these steps to deploy your Laravel application with Octane and Swoole:
- Navigate to your application's Settings tab
- Find the PHP runtime section
- Select FrankenPHP (Octane) as the runtime
- Save your settings
Enable the Swoole PHP extension
- Navigate to your application's Settings tab
- Find the PHP extensions section
- Enable the swoole extension
- Save your settings
Install Laravel Octane
Before deploying, install Laravel Octane in your application and commit the changes to your repository:
composer require laravel/octane
php artisan octane:install --server=swoole
Set the start command
Configure the start command in your application settings:
- Navigate to your application's Settings tab
- Find the Start command field
- Enter the following command:
php artisan octane:start --server=swoole --host=0.0.0.0 --port=8080
Deploy your application
After configuring the runtime, PHP extension, build commands, and start command, deploy your application. The deployment will:
- Build your application with the Swoole extension enabled
- Install Octane
- Start your application using the Swoole server
Frequently asked questions
What is the Swoole command for Laravel Octane?
Run `php artisan octane:start --server=swoole --host=0.0.0.0 --port=8080`. Set this as the start command in your application settings.
How do I install the Swoole PHP extension?
On Ploi Cloud, add `swoole` to the `php.extensions` array in your `ploi.yaml`. The platform installs it during the build via install-php-extensions — no manual PECL setup needed.
Does Laravel Octane support Swoole fibers?
Yes. Swoole fibers are supported automatically when running PHP 8.1+ with a recent Swoole version. Octane uses fibers for lightweight concurrency on long-running tasks.
When should I choose Swoole over RoadRunner or FrankenPHP?
Pick Swoole when you need maximum raw throughput and want native coroutine support for concurrent I/O inside request handlers. Pick FrankenPHP for the simplest setup; pick RoadRunner if you want Go-based stability without a PHP extension dependency.