Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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<string, string>`

### Fixed

- Errors thrown during the handling of a request were displayed

## 5.0.0 - 2025-07-13

### Changed
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -31,7 +31,7 @@
}
},
"require-dev": {
"innmind/static-analysis": "^1.2.1",
"innmind/static-analysis": "~1.3",
"innmind/coding-standard": "~2.0"
}
}
16 changes: 12 additions & 4 deletions src/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Factory\ServerRequestFactory,
Response\Sender\Native,
ServerRequest,
ServerRequest\Environment,
Response,
Response\StatusCode,
ProtocolVersion,
Expand All @@ -19,6 +18,7 @@
OperatingSystem,
Config,
};
use Innmind\Immutable\Map;

abstract class Main
{
Expand All @@ -36,12 +36,18 @@ final public function __construct(?Config $config = null)
return;
}

$this->preload($os, $request->environment());
/** @var Map<string, string> */
$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);
}

Expand All @@ -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<string, string> $env Environment variables
*/
protected function preload(OperatingSystem $os, Environment $env): void
protected function preload(OperatingSystem $os, Map $env): void
{
}

Expand Down