Skip to content
Corex

ApiResourceScaffolder

Corex\Cli\Generators\ApiResourceScaffolder · class · CLI layer

Scaffolds a complete, secured REST resource from one name (spec 046): a thin controller, its route registration (declaring the spec-005 middleware + a permission callback), a request-validation shape, a response resource (output DTO), and a test — under the app’s <base>/Api/ dir + namespace, answering with the spec-043 envelope. WP-CLI-independent and headless-testable: it only renders stubs and writes files (no WordPress). Render-all-before-write: an unresolved placeholder fails loudly without leaving a half-written resource on disk (mirrors BlockScaffolder).

__construct(StubRenderer $renderer, Naming $naming, string $stubsDir)

Section titled “__construct(StubRenderer $renderer, Naming $naming, string $stubsDir)”

scaffold(string $rawName, GeneratorContext $context, bool $force): ApiResourceScaffoldResult

Section titled “scaffold(string $rawName, GeneratorContext $context, bool $force): ApiResourceScaffoldResult”