Skip to content

Examples: 004-ApiJson — minimal JSON API endpoint (lint-first) #270

@PurHur

Description

@PurHur

Problem

Shipped examples stop at HTML pages (001-SimpleWeb, 002-StaticWeb). The north-star app (#67) needs a /api/status JSON route, but there is no small example that drives json_encode, http_response_code, and Content-Type: application/json through phpc lint / ExamplesCompileTest.

Goal

Add examples/004-ApiJson/example.php as a lint-first stub (like #246 for MiniWebApp):

header('Content-Type: application/json');
http_response_code(200);
echo json_encode(['ok' => true, 'service' => 'php-compiler']);

Start with phpc lint --json listing blockers; expand to VM smoke, then JIT/AOT when #61 / #252 close.

Scope

Acceptance criteria

Today (blockers expected):

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./phpc lint examples/004-ApiJson/example.php

exits 0 with structured unsupported nodes OR exits 0 with clean lint once blockers close.

When #61 + #252 land:

./phpc run examples/004-ApiJson/example.php

prints valid JSON; curl via phpc serve returns application/json.

Dependencies

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions