2.6.12 • Published 5 months ago

php-typescript-api v2.6.12

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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 or phpstan 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
2.6.1

6 months ago

2.6.0

6 months ago

2.6.3

6 months ago

2.6.2

6 months ago

2.6.11

5 months ago

2.6.12

5 months ago

2.6.10

5 months ago

2.6.5

6 months ago

2.6.4

6 months ago

2.6.7

5 months ago

2.6.6

5 months ago

2.6.9

5 months ago

2.6.8

5 months ago

2.5.0

1 year ago

2.4.0

1 year ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

3 years ago

1.0.17

3 years ago

2.0.3

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago