php-client icon indicating copy to clipboard operation
php-client copied to clipboard

JSON API for data access

Open Phoscur opened this issue 7 years ago • 1 comments

A PHP centered system always renders its template into HTML, but Web 2.0 SPAs render the DOM directly in the browser. Such web applications usually consume a REST JSON API .

  • short term: render variables that would be rendered into the html as a nested object/array JSON datastructure, so simple getJSON requests (requesting "application/json" datatype) can grab a state of the game too - this will achieve data access freedom (with session authorization, or better token bearer based authentication).

    • IMHO this would synergize well with the open(-source)ess of the project.
    • data serialization can be easily accomplished, e.g. U_Unit { .. public json_serialize: { json_encode($this) .. }
  • longterm: develop the interface design defining and refining it, covering all entities in further iterations

  • benefits: API spec is shared between client and server and is a perfect layer to write tests against. the spec wont depend on any implementation or language details - concentrating on the domain model entities and possible actions and their validation upon them.

Phoscur avatar Jun 03 '18 23:06 Phoscur

Automatic documentation and code generation: http://editor.swagger.io/

Phoscur avatar Aug 08 '18 12:08 Phoscur