# Laravel Octane

[Laravel Octane](https://laravel.com/docs/octane) aims at improving the performance of Laravel applications by serving them using high-powered application servers, including [Swoole](https://github.com/swoole/swoole-src), [Open Swoole](https://openswoole.com/), and [RoadRunner](https://roadrunner.dev/).

**Note**: 

Laravel Octane requires PHP 8.0+.

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

```yaml  {location=".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

Require Laravel Octane using Composer.

```bash
composer require laravel/octane
```

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

```bash
php artisan optimize:clear
```

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

```yaml  {location=".platform.app.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
```


