Skip to content

Add $_GET superglobal support for VM web scripts - #16

Merged
PurHur merged 1 commit into
masterfrom
feature/superglobal-get-vm
May 18, 2026
Merged

Add $_GET superglobal support for VM web scripts#16
PurHur merged 1 commit into
masterfrom
feature/superglobal-get-vm

Conversation

@PurHur

@PurHur PurHur commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wire up $_GET (and other CGI superglobal names) in the VM by resolving variable operands back to their CFG names and binding them to shared array variables in VM\Context.
  • Populate $_GET from QUERY_STRING or the new bin/vm.php -q 'name=value' flag via PHPCompiler\Web\Superglobals.
  • Add examples/001-SimpleWeb/example.php, a PHPT integration test (test/real/cases/web_get.phpt), and optional --ENV-- lines in PHPT files for the test harness.

Context

A small PHP web page needs request parameters ($_GET), safe output (htmlspecialchars — follow-up), and often multi-file include. This PR covers the first gap so VM mode can run minimal web-style scripts.

Test plan

  • QUERY_STRING='name=World&page=home' php bin/vm.php -r 'echo $_GET["name"];'
  • php bin/vm.php -q 'name=World' examples/001-SimpleWeb/example.php
  • php vendor/bin/phpunit test/real/RealWorldTest.php --filter web_get

Follow-ups

  • JIT / AOT support for superglobals and include in compiled binaries
  • htmlspecialchars() for escaped HTML output
  • $_POST, $_SERVER, null coalesce (??)

Made with Cursor

Populate query parameters from QUERY_STRING or bin/vm.php -q so compiled
pages can read request input like normal PHP. Includes a SimpleWeb example
and an integration PHPT with ENV section support in the test harness.

Co-authored-by: Cursor <cursoragent@cursor.com>
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