Skip to content

Web: DevServer default document (index.php) instead of hard-coded example.php #254

Description

@PurHur

Problem

lib/Web/DevServer.php maps GET / to /example.php unconditionally:

if ('/' === $path) {
    $path = '/example.php';
}

Shipped examples use example.php, but #210 / #246 MiniWebApp layout uses public/index.php as front controller. Developers must curl /index.php explicitly; curl http://127.0.0.1:8080/ fails for standard project layouts.

Goal

Directory index resolution matching common PHP dev servers:

  1. GET /index.php if present in docroot
  2. Else example.php (backward compatible with examples/001-SimpleWeb)
  3. Optional phpc.json key "index": "public/index.php" (DevEx: phpc.json project manifest (entry, includes, public assets) #106)

Implementation hints

Acceptance criteria

./phpc serve 127.0.0.1:8080 examples/003-MiniWebApp/public
curl -s 'http://127.0.0.1:8080/' | grep -q 'MiniWeb'

Works when index.php exists; examples/001-SimpleWeb still works via example.php fallback.

Verification (local only)

./script/ci-local.sh --filter ServeTest
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./script/ci-local.sh --filter ServeTest

Do not require GitHub Actions.

Dependencies

Related

Files

  • lib/Web/DevServer.php, test/real/ServeTest.php, lib/Web/ProjectManifest.php

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions