Skip to content

Feat/register phpinfo entries - #2578

Open
henderkes wants to merge 33 commits into
mainfrom
feat/register_phpinfo_entries
Open

Feat/register phpinfo entries#2578
henderkes wants to merge 33 commits into
mainfrom
feat/register_phpinfo_entries

Conversation

@henderkes

@henderkes henderkes commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

closes #2576

image

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?

@henderkes

Copy link
Copy Markdown
Contributor Author

@dunglas I think we should revert the last commit and make not passing the nobrotli tag a build error when libbrotli isn't available. It would shift the runtime error to a compile time error.

@dunglas

dunglas commented Jul 29, 2026

Copy link
Copy Markdown
Member

For watcher, this is because of e-dant/watcher#102

dunglas
dunglas previously requested changes Aug 4, 2026
Comment thread frankenphp.go Outdated
Comment thread frankenphp.go Outdated
Comment thread mercure.go
@henderkes
henderkes force-pushed the feat/register_phpinfo_entries branch 2 times, most recently from 33a4a54 to f1f8ca5 Compare August 4, 2026 16:25
@henderkes
henderkes force-pushed the feat/register_phpinfo_entries branch from f1f8ca5 to f06d146 Compare August 4, 2026 16:29
@henderkes

Copy link
Copy Markdown
Contributor Author

@dunglas I'm not sure if we really should rename AddPhpinfoEntry to AddPHPInfoEntry. Phpinfo refers to the phpinfo() function to print this.

@dunglas

dunglas commented Aug 4, 2026

Copy link
Copy Markdown
Member

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.

@henderkes

Copy link
Copy Markdown
Contributor Author

Alright, I'm okay with it like this either way.

@henderkes
henderkes requested a review from dunglas August 11, 2026 19:18
@henderkes

Copy link
Copy Markdown
Contributor Author

Reminder to self: cli registration logic is now split between <= 8.5 and >= 8.6. Needs a rebase.

@henderkes

Copy link
Copy Markdown
Contributor Author

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.

@henderkes
henderkes dismissed dunglas’s stale review September 3, 2026 19:30

All points resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread caddy/caddy.go Outdated
caddy.RegisterModule(&FrankenPHPAdmin{})

// Report Caddy version in phpinfo()
simpleVersion, fullVersion := caddy.Version()
Comment thread cli_test.go Outdated
Comment thread frankenphp.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread frankenphp.c
Comment thread frankenphp.c Outdated
Comment thread caddy/caddy.go Outdated
@henderkes
henderkes force-pushed the feat/register_phpinfo_entries branch from 632e412 to 6d5a4fd Compare September 8, 2026 17:21
Comment thread frankenphp.go Outdated
Comment on lines +176 to +185
func init() {
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
return
}

AddPHPInfoEntry("go", buildInfo.GoVersion)

goModuleEntries = buildGoModuleEntries(buildInfo)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to call this only when phpinfo() is called and not on init()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AlliBalliBaba AlliBalliBaba Sep 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's what you meant. I still don't really think it's advantageous over what we have though,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could still go for pinning instead of C allocations though. May help reduce code a little.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I'd prefer having it all in one place, but no hard block from me

@henderkes henderkes Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread watcher.go
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.

Add Caddy version to the FP version in phpinfo() results

5 participants