Laravel Octane with Swoole

2 min read Updated 14 hours 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