Skip to content

Add FrankenPhpHandler - #2056

Open
dunglas wants to merge 3 commits into
Seldaek:mainfrom
dunglas:frankenphp-handler
Open

Add FrankenPhpHandler#2056
dunglas wants to merge 3 commits into
Seldaek:mainfrom
dunglas:frankenphp-handler

Conversation

@dunglas

@dunglas dunglas commented Aug 4, 2026

Copy link
Copy Markdown

Adds a handler for FrankenPHP's frankenphp_log(), which writes structured logs through FrankenPHP's Go log/slog-based logger instead of error_log().

  • Guards on function_exists('frankenphp_log') in the constructor, throwing MissingExtensionException outside FrankenPHP (same pattern as ZendMonitorHandler).
  • Maps Monolog's 8 levels onto slog's level scale: the official FRANKENPHP_LOG_LEVEL_* constants for Debug/Info/Warning/Error, and custom ints for Notice/Critical/Alert/Emergency following slog's documented gap-of-4 convention for intermediate levels (see the docblock on FrankenPhpHandler::toFrankenPhpLevel()).
  • FrankenPhpHandlerE2ETest (tagged #[Group('e2e')]) makes real HTTP calls to a FrankenPHP server and inspects its structured log output, skipping itself if no server is reachable. CI runs it against dunglas/frankenphp:latest via a services: container in .github/workflows/frankenphp-e2e.yml.

dunglas added 3 commits August 4, 2026 16:17
Logs records using FrankenPHP's frankenphp_log() function, mapping
Monolog's levels onto slog's level scale, with an e2e test running
against a real FrankenPHP server.
Assert level and message come from the same structured log line
instead of independent substring checks, since the record's own raw
level int lands in the same JSON object as zap's level string. Also
mount the fixture app read-only.
write() was passing Monolog's own raw int "level" through to
frankenphp_log(), landing in the same JSON object as slog's own
"level" severity string under the same key - PHPUnit's json_decode()
silently keeps only the last one, so any consumer decoding this JSON
(including a naive test) would read the wrong field. Drop it
(level_name already carries the same info) and assert on decoded
JSON instead of regex now that the field is unambiguous.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant