diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ce6547..45d4ce1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,5 +7,3 @@ jobs: uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main cs: uses: innmind/github-workflows/.github/workflows/cs.yml@main - with: - php-version: '8.2' diff --git a/CHANGELOG.md b/CHANGELOG.md index f00bd88..425e8ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires PHP `8.4` +- Requires `innmind/operating-system:~7.0` +- `Innmind\HttpServer\Main::preload()` environment variables are now expressed with a `Innmind\Immutable\Map` + +### Fixed + +- Errors thrown during the handling of a request were displayed + ## 5.0.0 - 2025-07-13 ### Changed diff --git a/composer.json b/composer.json index 1dc9431..5cdf21b 100644 --- a/composer.json +++ b/composer.json @@ -15,9 +15,9 @@ "issues": "http://github.com/Innmind/HttpServer/issues" }, "require": { - "php": "~8.2", - "innmind/http": "~8.0", - "innmind/operating-system": "~6.0" + "php": "~8.4", + "innmind/http": "~9.0", + "innmind/operating-system": "~7.0" }, "autoload": { "psr-4": { @@ -31,7 +31,7 @@ } }, "require-dev": { - "innmind/static-analysis": "^1.2.1", + "innmind/static-analysis": "~1.3", "innmind/coding-standard": "~2.0" } } diff --git a/src/Main.php b/src/Main.php index c86ca0a..d2c2a34 100644 --- a/src/Main.php +++ b/src/Main.php @@ -7,7 +7,6 @@ Factory\ServerRequestFactory, Response\Sender\Native, ServerRequest, - ServerRequest\Environment, Response, Response\StatusCode, ProtocolVersion, @@ -19,6 +18,7 @@ OperatingSystem, Config, }; +use Innmind\Immutable\Map; abstract class Main { @@ -36,12 +36,18 @@ final public function __construct(?Config $config = null) return; } - $this->preload($os, $request->environment()); + /** @var Map */ + $env = Map::of(); + + foreach (\getenv() as $key => $value) { + $env = ($env)($key, $value); + } + + $this->preload($os, $env); try { $response = $this->main($request); } catch (\Throwable $e) { - throw $e; $response = $this->serverError($request); } @@ -58,8 +64,10 @@ final public function __construct(?Config $config = null) * rendered to the client. This is the expected behaviour so it's easier to * watch errors when developping the app. This method should never throw an * exception when in production mode. + * + * @param Map $env Environment variables */ - protected function preload(OperatingSystem $os, Environment $env): void + protected function preload(OperatingSystem $os, Map $env): void { }