Skip to content

fix: include FrankenPHP version in startup logs - #2551

Open
ousamabenyounes wants to merge 3 commits into
php:mainfrom
ousamabenyounes:fix/issue-2483
Open

fix: include FrankenPHP version in startup logs#2551
ousamabenyounes wants to merge 3 commits into
php:mainfrom
ousamabenyounes:fix/issue-2483

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds the FrankenPHP module version to startup log attributes when the running Go binary exposes it in build info.
  • Uses Go build info (debug/buildinfo) instead of the FRANKENPHP_VERSION cgo macro.
  • Keeps the startup log code in frankenphp.go and removes the separate startup log helper file.
Q A
Issues Fix #2483
Tests yes

Test verification (RED -> GREEN)

RED after adding the build-info regression tests before the review fix:

./startup_log_test.go:17:14: undefined: frankenPHPModulePath
./startup_log_test.go:23:12: undefined: frankenPHPVersionFromBuildInfo
./startup_log_test.go:31:13: undefined: frankenPHPModulePath
./startup_log_test.go:36:12: undefined: frankenPHPVersionFromBuildInfo
FAIL github.com/dunglas/frankenphp [build failed]

GREEN after the review cleanup:

./go.sh test -run "TestFrankenPHPVersionFromBuildInfo|TestFrankenPHPVersionFromExecutable|TestStartupLogAttrs" -count=1 .
ok github.com/dunglas/frankenphp 0.033s

Full local replay:

./run-ci.sh
ok github.com/dunglas/frankenphp 11.744s coverage: 73.0% of statements
ok github.com/dunglas/frankenphp/caddy 10.923s
?  github.com/dunglas/frankenphp/caddy/frankenphp [no test files]
diff-coverage-gate: PASS 100.00% (42/42) changed production lines covered

@dunglas

dunglas commented Jul 21, 2026

Copy link
Copy Markdown
Member

To me, this shouldn't be configurable with a Go API. This is already doable using build flags. I don't want to introduce the API surface for that.

ousamabenyounes added a commit to ousamabenyounes/frankenphp that referenced this pull request Jul 21, 2026
@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 73e6a61.

I removed the public Go option and the Caddy parser. The startup log version is now kept internal to the frankenphp package and set from Docker build flags with:

-X github.com/dunglas/frankenphp.frankenPHPVersion=$FRANKENPHP_VERSION

Local validation:

./go.sh test -run TestStartupLogAttrsIncludeBuildFlagFrankenPHPVersion -count=1 .
FRANKENPHP_EXPECT_LDFLAG_VERSION=1.12.4-test ./go.sh test -ldflags "-X github.com/dunglas/frankenphp.frankenPHPVersion=1.12.4-test" -run TestStartupLogAttrsIncludeBuildFlagFrankenPHPVersion -count=1 .
./go.sh test -count=1 .

@henderkes

Copy link
Copy Markdown
Contributor

I don't understand why this is necessary. We already have the caddy version string which includes the frankenphp version?

ousamabenyounes added a commit to ousamabenyounes/frankenphp that referenced this pull request Jul 23, 2026
@ousamabenyounes

ousamabenyounes commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Good point. The existing Caddy custom version is still the source used by frankenphp version, but it is not emitted in the current runtime startup log. Before this PR the startup log was only:

{"php_version":"...","num_threads":...,"max_threads":...,"max_requests":...}

I updated the patch so it does not add another Go ldflag or parse Caddy’s version string. FrankenPHP already has the FRANKENPHP_VERSION build-time macro for the PHP extension version, so the startup log now reads that internal value directly and emits it as a structured version attribute. That keeps this out of the public Go API and should cover the existing Docker, Windows, and static build paths that already set FRANKENPHP_VERSION.

Validated locally in the builder image:

./go.sh test -run TestStartupLogAttrsIncludeFrankenPHPVersion -count=1 .
FRANKENPHP_EXPECT_VERSION=1.12.4-test CGO_CFLAGS="-DFRANKENPHP_VERSION=1.12.4-test" ./go.sh test -run TestStartupLogAttrsIncludeFrankenPHPVersion -count=1 .
./go.sh test -count=1 .

ousamabenyounes added a commit to ousamabenyounes/frankenphp that referenced this pull request Jul 23, 2026
Comment thread caddy/app.go Outdated
Comment thread frankenphp.go Outdated
@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Addressed the remaining review follow-up: caddy/app.go is no longer part of the PR diff, and I replied on the version-source question explaining why the patch reuses the existing FRANKENPHP_VERSION C build flag instead of adding another Go ldflag path.

Validation: the pushed SHA c47ae88 has the full GitHub test/check matrix green; local check here: git diff --check.

@dunglas

dunglas commented Jul 24, 2026

Copy link
Copy Markdown
Member

I still don't understand the use case for having the version number in logs.

@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

@dunglas the use case is environments where operators only have access to centralized logs and not necessarily interactive shell access to the running instance. The startup log currently includes php_version, num_threads, max_threads and max_requests, but not the FrankenPHP version. Recording it there provides a simple deployment trace and helps identify which FrankenPHP version was started when reviewing startup logs. WDYT?

Comment thread startup_log.go Outdated
Comment thread frankenphp.go Outdated
Use Go build info instead of the FRANKENPHP_VERSION cgo macro for startup log version detection, and fold the log helper back into frankenphp.go.

RED->GREEN: build-info tests failed before the helper existed, then passed after the review cleanup. Local run-ci baseline/final tests pass before diff-coverage on committed HEAD.
@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Addressed the requested cleanup in c1fa1fe: the startup log version lookup now uses Go build info instead of the FRANKENPHP_VERSION cgo macro, and the separate startup_log.go helper file is gone.

Validation: reproduced the missing build-info helper as RED, then reran the focused tests GREEN. Full local run-ci.sh passed against the rebased branch with root package coverage, Caddy tests/build, tidy checks, and diff-coverage-gate: PASS 100.00% (42/42). GitHub checks are green for the pushed SHA.

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.

Include frankenphp version in logs

3 participants