Skip to content

Commit d2fba6e

Browse files
committed
Fixes
1 parent 91040d0 commit d2fba6e

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

layers/bootstrap.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@
1414
require $autoloadPath;
1515

1616
// `RUNTIME_CLASS` is for backwards compatibility with Bref v2's environment variable
17-
$runtimeClass = $_SERVER['BREF_RUNTIME'] ?? $_SERVER['RUNTIME_CLASS'];
17+
$runtime = $_SERVER['BREF_RUNTIME'] ?? $_SERVER['RUNTIME_CLASS'] ?? null;
1818

19-
if (empty($runtimeClass)) {
19+
if (empty($runtime)) {
2020
throw new RuntimeException('The environment variable `BREF_RUNTIME` is not set, are you trying to use Bref v2 with Bref v3 layers? Make sure to follow the Bref documentation to use the right layers for your current Bref version.');
2121
}
2222

23+
$runtimeClass = match ($runtime) {
24+
'function' => 'Bref\FunctionRuntime\Main',
25+
'fpm' => 'Bref\FpmRuntime\Main',
26+
'console' => 'Bref\ConsoleRuntime\Main',
27+
default => $runtime,
28+
};
29+
2330
if (! class_exists($runtimeClass)) {
2431
throw new RuntimeException("Bref is not installed in your application (could not find the class \"$runtimeClass\" in Composer dependencies). Did you run \"composer require bref/bref\"?");
2532
}

layers/php.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
; We want errors to be sent to stderr -> those will end up in CloudWatch
2-
; We don't want them on stdout because FPM would then send them to the browser
3-
display_errors=stderr
1+
; On the CLI we want errors to be sent to stdout -> those will end up in CloudWatch
2+
; In FPM workers we don't want that, but that is overridden by Bref when it starts PHP-FPM
3+
display_errors=1
44

55
; Since PHP 7.4 the default value is E_ALL
66
; We override it to set the recommended configuration value for production.

tests/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ test-%: vendor
1818
# Test function handler
1919
docker stop test-${CPU_PREFIX}php-$* 2> /dev/null || true # silence errors
2020
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$* \
21+
-e BREF_RUNTIME=function \
2122
bref/${CPU_PREFIX}php-$* test_4_function_handler.php
2223
docker exec test-${CPU_PREFIX}php-$* php test_4_function_invocation.php \
2324
|| (docker logs test-${CPU_PREFIX}php-$* && exit 1)
@@ -26,6 +27,7 @@ test-%: vendor
2627
# Test FPM handler
2728
docker stop test-${CPU_PREFIX}php-$* 2> /dev/null || true # silence errors
2829
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$* \
30+
-e BREF_RUNTIME=fpm \
2931
bref/${CPU_PREFIX}php-$* test_5_fpm_handler.php
3032
docker exec test-${CPU_PREFIX}php-$* php test_5_fpm_invocation.php \
3133
|| (docker logs test-${CPU_PREFIX}php-$* && exit 1) # print logs in case of failure
@@ -34,6 +36,7 @@ test-%: vendor
3436
# Test console handler
3537
docker stop test-${CPU_PREFIX}php-$* 2> /dev/null || true # silence errors
3638
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$* \
39+
-e BREF_RUNTIME=console \
3740
bref/${CPU_PREFIX}php-$* test_6_console_handler.php
3841
docker exec test-${CPU_PREFIX}php-$* php test_6_console_invocation.php \
3942
|| (docker logs test-${CPU_PREFIX}php-$* && exit 1) # print logs in case of failure
@@ -42,6 +45,7 @@ test-%: vendor
4245
# Test that we can override PHP_INI_SCAN_DIR
4346
docker stop test-${CPU_PREFIX}php-$*-test7 2> /dev/null || true # silence errors
4447
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$*-test7 \
48+
-e BREF_RUNTIME=function \
4549
-e PHP_INI_SCAN_DIR="/opt/bref/etc/php/conf.d/:/var/task/" \
4650
bref/${CPU_PREFIX}php-$* test_4_function_handler.php
4751
docker exec test-${CPU_PREFIX}php-$*-test7 php test_7_custom_ini_scan_dir.php \

tests/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"require": {
3-
"bref/bref": "dev-master"
3+
"bref/bref": "dev-single-layer"
44
},
55
"config": {
66
"platform": {
7-
"php": "8.0.7"
7+
"php": "8.2.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)