Download the PHP package allestuetsmerweh/php-typescript-api without Composer
On this page you can find all versions of the php package allestuetsmerweh/php-typescript-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download allestuetsmerweh/php-typescript-api
More information about allestuetsmerweh/php-typescript-api
Files in allestuetsmerweh/php-typescript-api
Package php-typescript-api
Short Description Build a typed Web API using PHP and TypeScript
License MIT
Homepage https://github.com/allestuetsmerweh/php-typescript-api
Informations about the package php-typescript-api
php-typescript-api
Build a typed Web API using PHP and TypeScript
Disclaimer: This is not an officially supported Google product
This project:
- helps with data validation on the server side by providing fields to define allowed request/response types.
- generates a typed API client in TypeScript.
- consists of a server (PHP) library, a client (TypeScript) library, and an example of its usage.
Usage
Server side (PHP)
-
Install php-typescript-api using composer:
composer require allestuetsmerweh/php-typescript-api
-
Implement some endpoints for your API (examples).
-
Define which endpoints your API contains (example).
-
Define how the TypeScript interface for your API should be generated (example).
-
Run that script in order to generate the TypeScript interface file:
php path/to/your/generate.php
(example result) - You might want to run this script automatically when starting your local dev server, and check in your CI pipeline whether the committed TypeScript interface file is up-to-date.
-
- Have a publicly reachable PHP script that serves the API (example).
Client side (TypeScript)
-
Install php-typescript-api using npm:
npm install --save php-typescript-api
-
Configure your API client (example).
- Use your API client to make requests (example).
Contribute
Build:
- Server: (no build necessary)
- Client:
npm run build
Run tests:
- Server:
composer test
- Client:
npm test
Lint:
- Server:
composer fix
- Client:
npm run lint
All versions of php-typescript-api with dependencies
php Version >=8.1
psr/log Version >=3.0
symfony/http-foundation Version >=6.1
phpstan/phpdoc-parser Version ^2.0