# Laravel Octane with Swoole

> Run Laravel Octane on Swoole: install Swoole + Octane, set the start command, configure workers and concurrency. Production-ready setup, step by step.

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:

<ol>
<li>Navigate to your application's <strong>Settings</strong> tab</li>
<li>Find the <strong>PHP runtime</strong> section</li>
<li>Select <strong>FrankenPHP (Octane)</strong> as the runtime</li>
<li>Save your settings</li>
</ol>

### Enable the Swoole PHP extension

<ol>
<li>Navigate to your application's <strong>Settings</strong> tab</li>
<li>Find the <strong>PHP extensions</strong> section</li>
<li>Enable the <strong>swoole</strong> extension</li>
<li>Save your settings</li>
</ol>

### Install Laravel Octane

Before deploying, install Laravel Octane in your application and commit the changes to your repository:

<pre><code>composer require laravel/octane
php artisan octane:install --server=swoole</code></pre>

### Set the start command

Configure the start command in your application settings:

<ol>
<li>Navigate to your application's <strong>Settings</strong> tab</li>
<li>Find the <strong>Start command</strong> field</li>
<li>Enter the following command:</li>
</ol>

<pre><code>php artisan octane:start --server=swoole --host=0.0.0.0 --port=8080</code></pre>

### Deploy your application

After configuring the runtime, PHP extension, build commands, and start command, deploy your application. The deployment will:

<ol>
<li>Build your application with the Swoole extension enabled</li>
<li>Install Octane</li>
<li>Start your application using the Swoole server</li>
</ol>

## 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.
