Laravel Octane with Swoole

2 min read Updated 4 months ago

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:

  1. Navigate to your application's Settings tab
  2. Find the PHP runtime section
  3. Select FrankenPHP (Octane) as the runtime
  4. Save your settings

Enable the Swoole PHP extension

  1. Navigate to your application's Settings tab
  2. Find the PHP extensions section
  3. Enable the swoole extension
  4. 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:

  1. Navigate to your application's Settings tab
  2. Find the Start command field
  3. 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:

  1. Build your application with the Swoole extension enabled
  2. Install Octane
  3. 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.