Skip to content

THRIFT-6498: Restore PHP tutorial server startup and HTTP calls - #4159

Closed
sveneld wants to merge 1 commit into
apache:masterfrom
sveneld:THRIFT-6498
Closed

sveneld wants to merge 1 commit into
apache:masterfrom
sveneld:THRIFT-6498

Conversation

@sveneld

@sveneld sveneld commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Jira: THRIFT-6498

The PHP tutorial server fails to load against the generated typed interfaces, and its Python 2 launcher no longer runs on Python 3. Even after startup is repaired, the malformed Content-Type header prevents the tutorial HTTP client from reading the response.

This change matches all five handler signatures to the generated interfaces, removes the web entry point's shebang, fixes the response header, and makes runserver.py launch PHP's built-in server on localhost:8080. The make target now tracks CalculatorProcessor.php and both IDL inputs instead of the obsolete Calculator.php filename.

A new end-to-end test runs the existing tutorial client against both php -S and runserver.py, checking ping, addition, the declared division-by-zero exception, subtraction, and getStruct output. It runs in the existing PHP 8.2–8.5 CI matrix. The test is included in EXTRA_DIST.

Validation:

  • Before the fix, both new tests fail on the namespace/shebang and Python 2 import errors.

  • After the fix, both tests pass on PHP 8.4.21 / Python 3.12 and PHP 8.5.11 / Python 3.13.

  • Built the current 0.26.0 compiler; clean tutorial generation, the subsequent make up-to-date check, PHP syntax checks, changed-file codespell, and git diff --check pass.

  • Repository-wide make style was run on a separate copy because it rewrites files. It fails on existing findings outside this change, including listin/siz in test/cpp/src/TestClient.cpp and ddress in test/crossrunner/report.py.

  • JIRA ticket exists and is assigned to sveneld.

  • PR title starts with the JIRA ticket ID.

  • One commit for this issue.

  • Compatibility considered: the launcher now serves locally through PHP; the tutorial endpoint and client command remain the same.

Generated-by: Codex (GPT-6)

Client: php

Match the generated handler signatures, serve the tutorial through the PHP
built-in HTTP server, and send a valid Content-Type header. Track the
actual generated processor in the tutorial make target.

Run the tutorial client against both HTTP entry points in the PHP CI
matrix and verify RPC output, including the declared exception.

Generated-by: Codex (GPT-6)
Copilot AI balanced review requested due to automatic review settings November 8, 2026 19:26
@mergeable mergeable Bot added php build and general CI cmake, automake and build system changes github_actions Pull requests that update GitHub Actions code labels Nov 8, 2026

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 PHP generation target can remain out of date when unchanged output timestamps are preserved, causing repeated compilation and a failing make -q check unless the target is touched or a generation stamp is used.

1 open issue
What changed in this PR

Restores the PHP tutorial’s HTTP workflow by aligning the server with generated interfaces and replacing the Python 2 launcher.

Changes:

  • Corrects handler signatures, removes the web entry point’s shebang, and fixes the response header.
  • Uses PHP’s built-in server and updates generated-file dependencies.
  • Adds end-to-end coverage for both server entry points in the existing PHP CI matrix.
File Description
tutorial/​php/​test_tutorial.py Adds HTTP client tests for both server entry points.
tutorial/​php/​runserver.py Replaces the Python 2 server with a Python 3 launcher for PHP.
tutorial/​php/​PhpServer.php Fixes startup compatibility and the HTTP response header.
tutorial/​php/​Makefile.am Updates generation dependencies, launcher invocation, and test distribution.
.github/​workflows/​build.yml Adds tutorial generation and end-to-end checks to PHP CI.

Review effort: Balanced

Comment thread tutorial/php/Makefile.am
Comment on lines +20 to 21
gen-php/tutorial/CalculatorProcessor.php: $(top_srcdir)/tutorial/tutorial.thrift $(top_srcdir)/tutorial/shared.thrift
$(THRIFT) --gen php:server -r $<
@sveneld

sveneld commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #4158, which addresses the same THRIFT-6498 tutorial server issues and was opened while this change was being prepared. The end-to-end tutorial tests and CI coverage in this branch remain available for reuse.

@sveneld sveneld closed this Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build and general CI cmake, automake and build system changes github_actions Pull requests that update GitHub Actions code php

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants