Skip to content

Add API scaffolding to the template; fix placeholder description - #5

Merged
HafizMMoaz merged 1 commit into
masterfrom
api-scaffolding
Jul 23, 2026
Merged

Add API scaffolding to the template; fix placeholder description#5
HafizMMoaz merged 1 commit into
masterfrom
api-scaffolding

Conversation

@HafizMMoaz

Copy link
Copy Markdown
Member

Closes zerp-pk/package-template#37.

New modules copied from this template now start API-ready instead of web-only.

Changes

  • composer.json — replaced "Description for example-package package" with a real one-line description.
  • src/Routes/api.php — the api.json + auth:sanctum group under the module slug, matching every other Zerp module (hrm, lead, taskly...), with a sample route wired up.
  • src/Http/Controllers/Api/ExamplePackageItemApiController — a sample controller returning a typed JsonResource collection (: AnonymousResourceCollection), the shape that gives Scramble a real response schema rather than an opaque object. Ties into zerp-pk/hrm#34's direction so new modules adopt the rich-OpenAPI pattern from day one.
  • src/Http/Resources/ExamplePackageItemResource — the resource whose typed, one-per-line fields Scramble reads.
  • ServiceProvider — loads api.php, plus a commented Scramble::registerApi(...) block to uncomment and rename once real endpoints exist (guarded with class_exists, exactly as hrm does it).

Verification

  • php -l clean on all new/changed files.
  • composer validate passes.
  • Existing template test suite still green (2 tests) — the provider boots with api.php loaded.

The sample controller extends App\Http\Controllers\Controller and uses App\Traits\ApiResponseTrait, which resolve inside the host app (the same as hrm's API controllers); route loading does not autoload the controller, so the isolated testbench suite is unaffected.

…on (#37)

New modules copied from this template now start API-ready instead of web-only.

- composer.json: replace "Description for example-package package" with a real
  one-line description.
- src/Routes/api.php: the api.json + auth:sanctum group under the module slug,
  matching every other Zerp module, with a sample route wired up.
- src/Http/Controllers/Api/ExamplePackageItemApiController: a sample controller
  returning a typed JsonResource collection, the shape that gives Scramble a real
  response schema.
- src/Http/Resources/ExamplePackageItemResource: the resource whose typed fields
  Scramble reads.
- ServiceProvider: load api.php, plus a commented Scramble::registerApi block to
  uncomment and rename once real endpoints exist.
@HafizMMoaz
HafizMMoaz requested a review from a team as a code owner July 23, 2026 06:47
@HafizMMoaz
HafizMMoaz merged commit f2a0256 into master Jul 23, 2026
2 checks passed
@HafizMMoaz
HafizMMoaz deleted the api-scaffolding branch July 23, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant