> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Swoole

> Use the Swoole extension on Upsun Cloud to run PHP applications with coroutine-based async networking.

> [!TIP]
>
> You can now use composable image to install runtimes and tools in your application container. To find out more, see the [Composable image](https://developer.upsun.com/docs/configure-apps/app-reference/composable-image.md) topic.

Swoole is a PHP extension that extends PHP core with a coroutine based asynchronous network application framework designed for building large scale concurrent systems.

Unlike PHP-FPM’s stateless operating, Swoole relies on establishing persistent connections with every user, sending and receiving data in real-time.

[Swoole](https://github.com/swoole/swoole-src) and [Open Swoole](https://openswoole.com/) are two forked libraries pursuing that goal.

> [!NOTE]
>
> The `swoole` and `openswoole` extensions are [available by default](https://developer.upsun.com/docs/languages/php/extensions.md) on Upsun Cloud PHP 8.2 Upsun Cloud containers.

For other versions of PHP, you can install both extensions manually by following the instructions on this page.\

You need:

* PHP 7.3+ for Swoole
* PHP 7.4.0+ for Open Swoole
* The [Swoole installation script](https://raw.githubusercontent.com/platformsh/snippets/main/src/install_swoole.sh).
  > [!NOTE]
  >
  > Currently, the installation script is compatible with PHP \<=8.0.\
  > It is **not** compatible with PHP 8.3,
  > and the `swoole` and `openswoole` extensions are **not** available on Upsun Cloud PHP 8.3 containers yet.

## Install

Install the PHP extension for Swoole or Open Swoole during the build.

Take advantage of an [installation script](https://raw.githubusercontent.com/platformsh/snippets/main/src/install_swoole.sh).
You need to pass 2 parameters:

* Which Swoole project to use: `openswoole` or `swoole`
* Which version to install


&#x20;   applications:
&#x20;       app:
&#x20;           type: 'php:\<VERSION>'
&#x20;           hooks:
&#x20;               build: |
&#x20;                   set -e
&#x20;                   ...
&#x20;                   curl -fsS https\://raw\.githubusercontent.com/platformsh/snippets/main/src/install\_swoole.sh | \{ bash /dev/fd/3 openswoole 4.11.0 ; } 3\<&0
&#x20;&#x20;

## Use

Override the default web server with a [custom start command](https://developer.upsun.com/docs/languages/php#alternate-start-commands).
Octane should listen on a TCP socket.


&#x20;   applications:
&#x20;     myapp:
&#x20;       type: 'php:\{\{version:php:latest}}'
&#x20;       web:
&#x20;         upstream:
&#x20;           socket\_family: tcp
&#x20;           protocol: http
&#x20;         commands:
&#x20;           start: php \<PATH\_TO\_SWOOLE\_START\_COMMAND> --port=\$PORT
&#x20;         locations:
&#x20;           "/":
&#x20;             passthru: true
&#x20;             scripts: false
&#x20;             allow: false


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.