Skip to content

DevEx: phpc init --profile apijson scaffold (004-ApiJson parity) #2000

@PurHur

Description

@PurHur

Problem

#632 / #1886 established phpc init --profile miniwebapp and sessionsweb with template parity checkers (#695, #1902). 004-ApiJson is a shipped JSON API example (http_response_code, json_encode) but contributors cannot scaffold it via CLI.

Goal

./phpc init --profile apijson my-api
./phpc lint my-api/example.php
./phpc run my-api/example.php

Produces a tree byte-synced to examples/004-ApiJson/ (policy like #695 / #1902).

Scope

Piece Path Notes
Template templates/init-apijson/ Copy from examples/004-ApiJson/ (example.php, phpc.json, README.md)
CLI lib/Cli/PhpcInit.php PROFILE_APIJSON = 'apijson'; help text
Parity checker #2029 script/check-init-apijson-parity.sh — implement there, not here
Test test/unit/PhpcInitApiJsonTest.php Mirror test/unit/PhpcInitSessionsWebTest.php
Docs docs/phpc-json.md, examples/README.md, ./phpc init --help Profile row

Implementation hints

  1. Copy templateexamples/004-ApiJson/example.php uses json_encode + http_response_code; keep minimal manifest:
{ "entry": "example.php", "binary": ".phpc/bin/app" }
  1. PhpcInit.php — add profile constant + copyTemplate('init-apijson', $target) branch (grep sessionsweb / PROFILE_SESSIONSWEB).

  2. PHPUnit — assert phpc init --profile apijson creates example.php + phpc.json; lint passes.

  3. After merge — flip APIJSON_INIT_PARITY_GATE=1 default in ci-fast (follow-up issue; checker tracked in DevEx: check-init-apijson-parity.sh — template ↔ examples/004-ApiJson (#695 pattern) #2029).

Acceptance criteria

./script/ci-fast.sh --filter PhpcInitApiJson
./phpc init --profile apijson /tmp/apijson-test && ./phpc lint /tmp/apijson-test/example.php

Verification (local / Docker only)

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  vendor/bin/phpunit --filter PhpcInitApiJson

No GitHub Actions.

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