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
php84orphp85(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
zipPHP 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:
- Configuration: the function handler, the Front Controller, environment variables and the host.
- Supported Applications: what a Front Controller may return, from a Kernel to a raw callable.
- Local development with the Emulator: running the function on your machine.
- Packaging and Deployment: shipping it to Scaleway, after a compatibility check.
- Logs: seeing what the function did.
Contributing
See CONTRIBUTING.md.
License
Released under the MIT License.