Skip to content

Commit c228caa

Browse files
committed
feature symfony#61522 [Runtime] Support runtime options as a string (VincentLanglet)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- [Runtime] Support runtime options as a string | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | Fix symfony#60755 | License | MIT cc `@nicolas`-grekas since I think you worked a lot on this. When setting the APP_RUNTIME_OPTIONS with docker or anything else than php, only a string can be used ; so it could be useful to support a string format for such options, I propose the classic json format and then use json_decode on string. WDYT ? I'm unsure how this template is tested... Commits ------- ecb9358 [Runtime] Support runtime options as a string
2 parents 329f0cf + ecb9358 commit c228caa

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/Runtime/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.4
55
---
66

7+
* Add JSON encoded value support for `APP_RUNTIME_OPTIONS`
78
* Add `FrankenPhpWorkerRunner`
89
* Add automatic detection of FrankenPHP worker mode in `SymfonyRuntime`
910

src/Symfony/Component/Runtime/Internal/autoload_runtime.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ if (!is_object($app)) {
1212
throw new TypeError(sprintf('Invalid return value: callable object expected, "%s" returned from "%s".', get_debug_type($app), $_SERVER['SCRIPT_FILENAME']));
1313
}
1414

15+
if (is_string($_SERVER['APP_RUNTIME_OPTIONS'] ??= $_ENV['APP_RUNTIME_OPTIONS'] ?? [])) {
16+
$_SERVER['APP_RUNTIME_OPTIONS'] = json_decode($_SERVER['APP_RUNTIME_OPTIONS'], true, 512, JSON_THROW_ON_ERROR);
17+
}
1518
$runtime = $_SERVER['APP_RUNTIME'] ?? $_ENV['APP_RUNTIME'] ?? %runtime_class%;
16-
$runtime = new $runtime(($_SERVER['APP_RUNTIME_OPTIONS'] ?? $_ENV['APP_RUNTIME_OPTIONS'] ?? []) + %runtime_options%);
19+
$runtime = new $runtime($_SERVER['APP_RUNTIME_OPTIONS'] += %runtime_options%);
1720

1821
[$app, $args] = $runtime
1922
->getResolver($app)

0 commit comments

Comments
 (0)