Swoole

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 and Open Swoole are two forked libraries pursuing that goal.

Check the documentation related to Laravel Octane on Platform.sh.

Install 

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

Take advantage of an installation script. You need to pass 2 parameters:

  • Which Swoole project to use: openswoole or swoole
  • Which version to install
.platform.app.yaml
hooks:
    build: |
        set -e
        ...
        curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_swoole.sh | { bash /dev/fd/3 openswoole 4.11.0 ; } 3<&0        

Use 

Override the default web server with a custom start command. Octane should listen on a TCP socket.

.platform.app.yaml
web:
    upstream:
        socket_family: tcp
        protocol: http
    commands:
        start: php path/to/swoole/start/command --port=$PORT
    locations:
        "/":
            allow: false
            passthru: true