jdecool/scaleway-runtimepublic Fork
⑂ main
Commits
⬇ Clone ▾
git clone https://git.rickub.com/jdecool/scaleway-runtime.git
git clone ssh://git@rickub.com/jdecool/scaleway-runtime.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP
docs: split the README into a documentation folder organised by domain a4d5deaUnverified · on main · Jérémy DECOOL · 2d ago
README.md · 65 lines · 3.0 KBmarkdown
Blame HistoryOpen raw

Scaleway Runtime

A Symfony Runtime that runs Symfony and PHP applications on Scaleway Serverless Functions.

Scaleway calls a PHP function handle($event, $context) for each Invocation.
This package provides that function, boots your unchanged public/index.php once per Warm Process, turns each Event into a Symfony Request and each Response back into a Function Response.
It also ships the tools to package the function and to run it locally.

Vocabulary (Invocation, Event, Warm Process...) is defined in GLOSSARY.md, design decisions in docs/adr.

[!IMPORTANT]
The platform facts the runtime relies on were measured on Scaleway with the probe, see docs/probe-results.md.
The example application runs on Scaleway: its scenarios, CRON triggers and Command Invocations were checked on a deployment.

Requirements

  • The Scaleway PHP runtimes php84 or php85 (PHP 8.4 or later).
  • Symfony 7.4 or 8.x components (symfony/runtime, symfony/http-kernel, symfony/http-foundation).
  • To build the deployment zip: the zip PHP extension.
  • macOS or Linux for the packaging and Emulator tools (see Windows).

Installation

composer require jdecool/scaleway-runtime
vendor/bin/scaleway-init

scaleway-init writes handler.php at the root of your application:

<?php

require __DIR__.'/vendor/autoload.php';

function handle(array $event, mixed $context): array
{
    return JDecool\ScalewayRuntime\Handler::handle($event, $context);
}

Commit it.
scaleway-init refuses to replace a handler.php that differs from this stub, unless run with --force.

Your Front Controller stays as it is, require_once dirname(__DIR__).'/vendor/autoload_runtime.php' included.
That file is generated by the symfony/runtime Composer plugin, so the plugin must be allowed (config.allow-plugins.symfony/runtime), as Symfony Flex applications already do.
The Handler has already loaded vendor/autoload.php when the Front Controller runs, so autoload_runtime.php returns early and the runtime of this package takes over.

Documentation

The documentation index lists every guide. The usual path:

  1. Configuration: the function handler, the Front Controller, environment variables and the host.
  2. Supported Applications: what a Front Controller may return, from a Kernel to a raw callable.
  3. Local development with the Emulator: running the function on your machine.
  4. Packaging and Deployment: shipping it to Scaleway, after a compatibility check.
  5. Logs: seeing what the function did.

Contributing

See CONTRIBUTING.md.

License

Released under the MIT License.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Scaleway Runtime

A [Symfony Runtime](https://symfony.com/doc/current/components/runtime.html) that runs Symfony and PHP applications on [Scaleway Serverless Functions](https://www.scaleway.com/en/serverless-functions/).

Scaleway calls a PHP function `handle($event, $context)` for each Invocation.
This package provides that function, boots your unchanged `public/index.php` once per Warm Process, turns each Event into a Symfony `Request` and each `Response` back into a Function Response.
It also ships the tools to package the function and to run it locally.

Vocabulary (Invocation, Event, Warm Process...) is defined in [GLOSSARY.md](GLOSSARY.md), design decisions in [docs/adr](docs/adr/README.md).

> [!IMPORTANT]
> The platform facts the runtime relies on were measured on Scaleway with the [probe](probe), see [docs/probe-results.md](docs/probe-results.md).
> The [example application](example) runs on Scaleway: its scenarios, CRON triggers and Command Invocations were checked on a deployment.

## Requirements

- The Scaleway PHP runtimes `php84` or `php85` (PHP 8.4 or later).
- Symfony 7.4 or 8.x components (`symfony/runtime`, `symfony/http-kernel`, `symfony/http-foundation`).
- To build the deployment zip: the `zip` PHP extension.
- macOS or Linux for the packaging and Emulator tools (see [Windows](docs/local-development.md#windows)).

## Installation

```sh
composer require jdecool/scaleway-runtime
vendor/bin/scaleway-init
```

`scaleway-init` writes `handler.php` at the root of your application:

```php
<?php

require __DIR__.'/vendor/autoload.php';

function handle(array $event, mixed $context): array
{
    return JDecool\ScalewayRuntime\Handler::handle($event, $context);
}
```

Commit it.
`scaleway-init` refuses to replace a `handler.php` that differs from this stub, unless run with `--force`.

Your Front Controller stays as it is, `require_once dirname(__DIR__).'/vendor/autoload_runtime.php'` included.
That file is generated by the `symfony/runtime` Composer plugin, so the plugin must be allowed (`config.allow-plugins.symfony/runtime`), as Symfony Flex applications already do.
The Handler has already loaded `vendor/autoload.php` when the Front Controller runs, so `autoload_runtime.php` returns early and the runtime of this package takes over.

## Documentation

The [documentation index](docs/README.md) lists every guide. The usual path:

1. [Configuration](docs/configuration.md): the function handler, the Front Controller, environment variables and the host.
2. [Supported Applications](docs/applications.md): what a Front Controller may return, from a Kernel to a raw callable.
3. [Local development with the Emulator](docs/local-development.md): running the function on your machine.
4. [Packaging](docs/packaging.md) and [Deployment](docs/deployment.md): shipping it to Scaleway, after a [compatibility check](docs/compatibility-check.md).
5. [Logs](docs/logs.md): seeing what the function did.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

## License

Released under the [MIT License](LICENSE).