Skip to content

Web: Migrate 003-MiniWebApp from ?route= to PATH_INFO URLs #489

@PurHur

Description

@PurHur

Problem

examples/003-MiniWebApp/public/index.php uses ?route=home query dispatch for the skeleton phase. Production-style front controllers use PATH_INFO after index.php (e.g. /index.php/hello?name=Dev), which lib/Web/DevServer.php already populates (#276 ✅) and ServeTest covers.

#210 route table still documents path-style URLs (/hello, /contact) while the shipped tree uses $_GET['route']. Contributors cannot validate realistic URLs until migration lands.

Goal

After #67 VM serve is green with ?route=, migrate routing to PATH_INFO (keep ?route= as deprecated fallback optional v1):

Method URL Behavior
GET /index.php or / Home
GET /index.php/hello?name= Greet
POST /index.php/contact Form thank-you
GET /index.php/api/status JSON

Implementation hints

  1. public/index.php: derive $route from $_SERVER['PATH_INFO'] (trim /, default home); fallback to $_GET['route'] during transition.
  2. src/Router.php: normalize route keys (hello, contact, api/status) — same switch as today.
  3. examples/003-MiniWebApp/README.md: curl recipes for PATH_INFO + note Web: Extend script/examples-web-smoke.sh for 003-MiniWebApp routes #461 / Testing: ServeTest MiniWebApp routes via phpc serve (skipped until #67) #470 needles.
  4. Tests: extend Testing: ServeTest MiniWebApp routes via phpc serve (skipped until #67) #470 / Web: Extend script/examples-web-smoke.sh for 003-MiniWebApp routes #461 with PATH_INFO curls; add Stdlib: JIT/AOT extract() and compact() (#476) #487 PHPT if needed.

Acceptance criteria

cd examples/003-MiniWebApp
../../phpc serve 127.0.0.1:8080 .
curl -s 'http://127.0.0.1:8080/index.php/hello?name=Dev'
curl -s 'http://127.0.0.1:8080/index.php/api/status'

Bodies match Zend PHP 8 on the same tree.

Verification (local / Docker only)

make examples-web-smoke   # after #461 extended
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./script/ci-local.sh --filter ServeMiniWebApp

No GitHub Actions required.

Dependencies

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:webWeb / CGI / superglobalsenhancementNew feature or requestphase-5:reference-appPhase 5 – reference web application

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions