Skip to content

Facts-and-Files/tp-api

Repository files navigation

Run tests

Transcribathon platform API

Version 2 of the Transcribathon platform API (tp-api) as PHP Laravel stack.

Requirements for development

There are two docker containers/images required.

  • TP-MySQL The MySQL docker container which will provide the database (the dump will be provided on demand).
  • trenc-php An custom PHP image. When bulding the image use the name and tag as it is referenced in the docker-compose.yml here (scto-php:8.0).

Development/Helpers

A Makefile is included for managing some of the processes as starting/stoping the docker container.

$ make serve

$ make stop

artisan

To get direct access to the docker internal Laravel artisan console (and not the one from the host) you can use the provided d_artisan.sh wrapper script:

$ ./docker_artisan.sh list

Composer

Also the you can make use of the docker container internal compose with the provided wrapper:

$ ./docker_composer.sh --version

API-Token

To access the API routes a valid token is required. The token can be generated via

$ ./docker_artisan.sh make:token

It will be stored in the api_clients table as hash. The token can be applied by the client as as bearer token in the header Authorization: Bearer <api_token>

Development

For deployment see Makefile. Head to https://laravel.com/docs/9.x/deployment#main-content for server requirements. Probably the PHP DOM extension is missing by default.

$ sudo apt upate && sudo apt install php8.0-xml

If needed (on initial install) connect to the deploy server and run the

$ php artisan migrate

manually to alter the database.

API routes

There is an OpenAPI console available. It can be accessed via:

Access to all routes require a bearer token.