Feat/register phpinfo entries - #2578
Conversation
|
@dunglas I think we should revert the last commit and make not passing the |
|
For watcher, this is because of e-dant/watcher#102 |
33a4a54 to
f1f8ca5
Compare
f1f8ca5 to
f06d146
Compare
|
@dunglas I'm not sure if we really should rename |
|
I'm not sure either but this sounds more idiomatic to me. People who will call this function will do it in Go, it in PHP. |
|
Alright, I'm okay with it like this either way. |
|
Reminder to self: cli registration logic is now split between <= 8.5 and >= 8.6. Needs a rebase. |
…_entries # Conflicts: # cli.go # cli_test.go # frankenphp.c
|
Cli registration now works in both paths (<=8.5 and >=8,.6). Last commit is technically unrelated to the branch, I just got tired of the tests failing locally due to my ini settings. |
There was a problem hiding this comment.
🟡 Changes recommended
The primary Caddy-version behavior lacks direct integration coverage, and minor documentation issues remain.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds FrankenPHP, Caddy, Go toolchain, and linked-module metadata to phpinfo() across server and CLI modes.
Changes:
- Registers and renders sorted PHP info entries.
- Reports versions for Caddy, Mercure, watcher, Brotli, and Go modules.
- Extends CLI lifecycle and metadata tests.
File summaries
| File | Description |
|---|---|
worker_test.go |
Enables displayed HTML errors. |
watcher.go |
Registers watcher metadata. |
types_test.go |
Tests module-entry generation. |
testdata/command-detached.php |
Adds detached-process fixture. |
server_test.go |
Enables displayed errors. |
mercure.go |
Registers Mercure metadata. |
go.mod |
Promotes x/sys to direct dependency. |
frankenphp.h |
Declares PHP info arrays. |
frankenphp.go |
Builds and manages metadata entries. |
frankenphp.c |
Renders metadata and registers CLI module. |
frankenphp_test.go |
Tests rendered metadata. |
emulate_php_cli.c |
Enables text-mode CLI phpinfo. |
cli.go |
Initializes metadata for CLI execution. |
cli_test.go |
Expands CLI behavior coverage. |
cli_linux_test.go |
Tests detached Linux children. |
caddy/caddy.go |
Registers Caddy version. |
caddy/br.go |
Registers Brotli metadata. |
Review details
- Files reviewed: 17/17 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| caddy.RegisterModule(&FrankenPHPAdmin{}) | ||
|
|
||
| // Report Caddy version in phpinfo() | ||
| simpleVersion, fullVersion := caddy.Version() |
…_entries # Conflicts: # frankenphp.go
There was a problem hiding this comment.
🟡 Changes recommended
The requested Caddy-version path still lacks a Caddy-package integration assertion, as noted in the unresolved review thread.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 0 new
- Review effort level: Balanced
632e412 to
6d5a4fd
Compare
| func init() { | ||
| buildInfo, ok := debug.ReadBuildInfo() | ||
| if !ok { | ||
| return | ||
| } | ||
|
|
||
| AddPHPInfoEntry("go", buildInfo.GoVersion) | ||
|
|
||
| goModuleEntries = buildGoModuleEntries(buildInfo) | ||
| } |
There was a problem hiding this comment.
Would it make sense to call this only when phpinfo() is called and not on init()?
There was a problem hiding this comment.
We could do it, but it's more code, locking for the first phpinfo call, and we'd need to hook phpinfo. I don't think it's worth it given it's just a one-time cost on Init.
There was a problem hiding this comment.
I don't think we need to hook into phpinfo, we just need to fetch the info from go in the PHP_MINFO_FUNCTION, unless I'm missing something.
There was a problem hiding this comment.
Would only need pinning, no allocations.
PHP_MINFO_FUNCTION(frankenphp) {
char **frankenphp_phpinfo_entries = go_get_frankenphp_info_entries()
....Maybe even simpler would be to call C.php_info_print_table_row(...) directly from go, which does not even require pinning (unless this is a macro)
There was a problem hiding this comment.
Ah that's what you meant. I still don't really think it's advantageous over what we have though,
There was a problem hiding this comment.
I could still go for pinning instead of C allocations though. May help reduce code a little.
There was a problem hiding this comment.
In that case I'd prefer having it all in one place, but no hard block from me
There was a problem hiding this comment.
Do you mean the module version reads? The reason they're scattered is because I want to only show versions of modules the build actually has enabled. If we just registered everything at once in frankenphp.go, it would always list e.g. mercure even if-tags=nomercure was used.
The phpinfo logic stuff we can move out to its own go file.
There was a problem hiding this comment.
Hmm is the module still present if it is built with -tags=nomercure? In that case I guess this is the only way, otherwise I'd prefer just looping once over debug.ReadBuildInfo() when the PHP_MINFO_FUNCTION is called instead of having it spread out with many init()
There was a problem hiding this comment.
Yeah, the module is still present in build info. We could read the build info once and then toggle the main entries from the module, but honestly it doesn't really matter.
I should try moving all the logic into its own file where possible though. It really clutters frankenphp.go a bit.
closes #2576
Edit: the entries are sorted now.
@dunglas I know you've worked on the watcher-go library before, perhaps you could expose a proper version number instead?