Upsun User Documentation

Laravel Octane

Back to home

On this page

Upsun Beta access

Test and provide feedback for our newest offering - Upsun!

You can register for the Beta by clicking here and completing the form.

Sign up for Beta access

Laravel Octane aims at improving the performance of Laravel applications by serving them using high-powered application servers, including Swoole, Open Swoole, and RoadRunner.

Install Anchor to this heading

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
.upsun/config.yaml
applications:
    app:
        type: 'php:<VERSION>'
        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 Anchor to this heading

To retrieve Laravel Octane, use Composer.

composer require laravel/octane

Then make sure to clear the cache on all relevant Upsun environments.

upsun ssh
php artisan optimize:clear

Override the default web server with a custom start command. Octane should listen on a TCP socket. To do so, update your the configuration of your Laravel container in the applications top-level key of your .upsun/config.yaml file.

.upsun/config.yaml
web:
    upstream:
        socket_family: tcp
        protocol: http
    commands:
        start: php artisan octane:start --server=swoole --host=0.0.0.0 --port=$PORT
    locations:
        "/":
            passthru: true
            scripts: false
            allow: false

Is this page helpful?