2.4 KiB
2.4 KiB
AGENTS.md
Project overview
APIlite is a lightweight PHP library. A class extends TPsoft\APIlite\APIlite, public methods become API actions, requests are processed automatically, and responses are returned as JSON.
The project also generates frontend clients:
- JavaScript client:
format=javascript(.js, includesbearerSet()helper backed bylocalStorage) - TypeScript client:
format=typescript(.ts, real typed output, includesbearerSet()helper backed bylocalStorage)
The HTML help page is also interactive:
- HTML help:
format=htmlincludes endpoint docs, a built-in request tester, and optional Bearer token support stored in browserlocalStorage
Core files
src/APIlite.php: runtime, routing, docs JSON/HTML/client generationsrc/help.tpl.php: HTML documentation templatesrc/javascript.tpl.php: JavaScript client templatesrc/typescript.tpl.php: TypeScript client templatebin/apilite-files: helper script for bootstrapping files in consumer projects
Working rules
- Keep API behavior backward compatible unless explicitly requested.
- Maintain both generated clients:
- JavaScript stays plain JS.
- TypeScript stays typed (interfaces + typed method signatures).
- Bearer token behavior stays aligned between JavaScript and TypeScript clients (
bearerSet(),apilite_bearer_token, automaticAuthorization: Bearer ...header).
- Keep the HTML help page usable both as documentation and as a lightweight in-browser tester.
- If you change output field names in JSON help, update README and templates consistently.
- If you change request metadata or tester behavior, update
README.mdand keepsrc/help.tpl.phpaligned with the actual runtime request model. - Prefer small, focused changes over broad rewrites.
Verification checklist
- Run syntax checks on edited PHP files:
php -l src/APIlite.phpphp -l src/help.tpl.phpphp -l src/javascript.tpl.phpphp -l src/typescript.tpl.phpphp -l bin/apilite-files
- If HTML help changes, also render it once:
php test/APIcalculator.php --html
- If client generation changes, test with:
php test/APIcalculator.php --javascriptphp test/APIcalculator.php --typescript
Documentation rule
When output format names/flags/URLs change, update README.md in the same change set.
When Bearer token helper/storage behavior changes, update README.md and keep JS/TS client docs aligned with the actual generated templates.