# APIlite A set of tools to simplify the work of creating backend APIs for your frontend projects. Includes tutorials, patterns and practical examples for creating projects based on REST APIs. ## Installation Download source code and add to your project ```php The HTML documentation page also includes a built-in interactive tester. Each endpoint can be expanded with `Try it`, filled directly in the browser, and executed against the current API endpoint. If needed, you can set a shared Bearer token at the top of the page. The token is stored in `localStorage` and is sent as `Authorization: Bearer ...` for test requests made from that page. You can also download generated frontend clients: * JavaScript: `?format=javascript` * TypeScript (typed for Vue/TS projects): `?format=typescript` JavaScript usage example: ```js import backend from './backend.js'; backend.add(1, 2).then((response) => { console.log(response.data); }); ``` TypeScript usage example (Vue + TS): ```ts import backend from './backend'; backend.add(1, 2).then((response) => { console.log(response.data); // typed value based on PHP return type }); ``` If a method return type is a PHP class with public properties, JSON help now also includes `return_structure`, and the generated TypeScript client maps that class to an object shape based on those public properties. These outputs can also be generated in command line: * HTML: `$> php APIcalculator.php --html` * JavaScript: `$> php APIcalculator.php --javascript > backend.js` (`--js` alias is available) * TypeScript: `$> php APIcalculator.php --typescript > backend.ts` ## HTML help tester notes The built-in HTML tester currently follows the default APIlite request model: * request method is `POST` * endpoint action is sent as query parameter `action` * request fields are sent as top-level form fields * object and array field values are serialized as JSON strings Because the current metadata does not explicitly distinguish path params, query params and request body schemas, the HTML tester renders the parts that are reliably available today and keeps the rest minimal.