jdecool/scaleway-runtimepublic Fork
⑂ 637e0aa
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

feat(example): add a function-like Front Controller returning a ResponseUnverified

Jérémy DECOOL committed 2026-11-13T22:36:39+01:00 Browse files
637e0aa parent: d8b9157
modified example/README.md +3 -0
@@ -12,6 +12,9 @@ A minimal Symfony application running on Scaleway Serverless Functions through `
1212 | `GET /counter` | A per-process invocation counter: it keeps growing while a Warm Process serves the Invocations |
1313 | `POST /` | Where CRON Invocations land, with the trigger's arguments as JSON body |
1414
15+`public/hello.php` is a second, function-like Front Controller: a closure taking the `Request` and returning a `Response`, called for every Invocation without any Kernel.
16+Select it with the `front_controller` runtime option, for instance `APP_RUNTIME_OPTIONS='{"front_controller":"public/hello.php"}' vendor/bin/scaleway-serve`, then `curl 'http://127.0.0.1:8000/?name=Scaleway'`.
17+
1518 ## Run it locally
1619
1720 ```sh
@@ -12,6 +12,9 @@ A minimal Symfony application running on Scaleway Serverless Functions through `
12 | `GET /counter` | A per-process invocation counter: it keeps growing while a Warm Process serves the Invocations |12 | `GET /counter` | A per-process invocation counter: it keeps growing while a Warm Process serves the Invocations |
13 | `POST /` | Where CRON Invocations land, with the trigger's arguments as JSON body |13 | `POST /` | Where CRON Invocations land, with the trigger's arguments as JSON body |
14 14
15+`public/hello.php` is a second, function-like Front Controller: a closure taking the `Request` and returning a `Response`, called for every Invocation without any Kernel.
16+Select it with the `front_controller` runtime option, for instance `APP_RUNTIME_OPTIONS='{"front_controller":"public/hello.php"}' vendor/bin/scaleway-serve`, then `curl 'http://127.0.0.1:8000/?name=Scaleway'`.
17+
15 ## Run it locally18 ## Run it locally
16 19
17 ```sh20 ```sh
added example/public/hello.php +11 -0
new file mode 100644
@@ -0,0 +1,11 @@
1+<?php
2+
3+use Symfony\Component\HttpFoundation\JsonResponse;
4+use Symfony\Component\HttpFoundation\Request;
5+
6+require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
7+
8+// A function-like Front Controller: no Kernel, called for every Invocation with its Request.
9+return static function (Request $request): JsonResponse {
10+ return new JsonResponse(['message' => sprintf('Hello %s!', $request->query->get('name', 'World'))]);
11+};
new file mode 100644
@@ -0,0 +1,11 @@
1+<?php
2+
3+use Symfony\Component\HttpFoundation\JsonResponse;
4+use Symfony\Component\HttpFoundation\Request;
5+
6+require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
7+
8+// A function-like Front Controller: no Kernel, called for every Invocation with its Request.
9+return static function (Request $request): JsonResponse {
10+ return new JsonResponse(['message' => sprintf('Hello %s!', $request->query->get('name', 'World'))]);
11+};