Skip to content

AOT: PHPC_DEPLOY_ROOT for runtime template includes in deployed binaries #585

@PurHur

Description

@PurHur

Problem

ProjectGraph already discovers templates/*.php for phpc build --project dry-run (#504 ✅, test/unit/ProjectGraphTest.php). Router renders views with:

include __DIR__ . '/../templates/layout.php';

VM phpc serve keeps sources on disk, so __DIR__ resolves. A relocated native binary (production CGI, #50, #180) may run with a different cwd and no sibling templates/ tree — includes fail silently or with missing-file errors even when link succeeds (#568).

Goal

Documented, testable deploy root so AOT bundles resolve template paths outside the compile tree:

cd examples/003-MiniWebApp
../../phpc build --project .
PHPC_DEPLOY_ROOT=/opt/miniwebapp ./.phpc/bin/app   # finds bundled templates

Scope

  • Env PHPC_DEPLOY_ROOT (or manifest field deployRoot) consumed by AOT runtime / SourceBundler include resolver
  • phpc deploy / #180 copies templates/ + assets/ beside binary using same root
  • Compliance or unit test: build fixture project, run binary from temp dir with env set, assert template output needle

Out of scope

  • PSR-4 autoload (#155)
  • nginx/FastCGI wiring (#445)

Acceptance criteria

make docker-build-22   # once
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  bash -lc './script/ci-local.sh --filter DeployRootTest'
# or harness: ./script/docker-ci-local.sh --filter DeployRootTest

Test passes when binary run from a non-source cwd prints expected HTML fragment.

Links

  • North star: #78 Phase 3 Web AOT
  • Blocked by / pairs with: #568, #180, #485
  • Reference app: examples/003-MiniWebApp/

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphase-3:aotPhase 3 – AOT deployment

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions