Unzählige Tools in allen Sprachen unterstützen einen dabei, solide APIs zu bauen, aber die Symfony-basierte api-platform sticht hervor: mit ihr erstellt man OpenAPI-kompatible REST-Schnittstellen nur mit Hilfe von einfachen Code-Annotationen. Stefan präsentiert zunächst die Basisinstallation des Frameworks und stellt seine wichtigsten Features vor, um dann tiefer in produktive Details einzusteigen. Darunter, wie man Client-Code und SPA-Frontends automatisch generiert, datenbankbasierte Akzeptanztests in Behat und Mink schreibt, sich per JWT authentifiziert, Custom Endpoints erstellt und von Doctrine ORM unabhängige Datenquellen nutzt. Schließlich demonstriert er, wie sich die produktive Vue.js-SPA seines Projekts via Apollo-Client mit automatisch generierten GraphQL-Endpunkten verbindet, ohne einen einzigen Resolver schreiben zu müssen und wie das brandneue Mercure-Protokoll dafür sorgt, dass das Frontend automatisch mitbekommt, wenn sich Daten auf dem Server ändern.
2. Hello, I am
Stefan Adolf
Developer Ambassador
Turbine Kreuzberg
@stadolf
#reactjs #mongodb #blockchain #codingberlin
#elastic #symfony #turbinejetzt #microservices
4. HATEOAS
Hypermedia as the engine of application state
Responses enthalten “Links” auf verwandte Resourcen
❏ Welche Links angeboten werden, hängt vom Status der Resource ab
Clients entscheiden, ob / was sie daraus machen
❏ “code on demand”
17. JSON-LD
JSON for linking data
Data is messy and disconnected.
JSON-LD organizes and connects it,
creating a better Web. Hydra is a lightweight vocabulary to create
hypermedia-driven Web APIs.
By specifying a number of concepts commonly used in
Web APIs it enables the creation of generic API clients
Markus
Hydra Core Vocabulary
Relationen, Links & Operationen
Markus Lanthaler
20. application/vnd.api+json
JSON:API
A SPECIFICATION FOR BUILDING APIS IN JSON
If you’ve ever argued with your team about the way
your JSON responses should be formatted,
JSON:API can be your anti-bikeshedding tool.
33. Realtime updates
composer require mercure
Installiere einen Mercure Hub
❏ z.B. Docker oder Binary
❏ Plaintext-Secret
❏ JWT mit publish-Eintrag
❏ Bestandteil der offiziellen Distribution
@ApiResource(mercure=true)
34. Realtime updates
GET /products/1 HTTP/1.1
Host: sfliveapi.herokuapp.com
Accept: application/ld+json
Content-Type: application/json
HTTP/1.1 200 OK
Link: <https://sfliveapi.herokuapp.com/docs.jsonld>;
rel="http://www.w3.org/ns/hydra/core#apiDocumentation"
,<https://mercuresflive.stadolf.de/hub>; rel="mercure"
Clients wissen jetzt, dass der Hub sie bei
Änderungen benachrichtigen wird.
39. Dinge ohne Demo.
docker / docker-compose dev env
Helm Charts für K8S deployment
http/2 push
❏ Der Server sendet verwandte Resourcen selbst an den Client
RDFa-Support / Schema Generator
❏ DRtW: Erzeuge neue Entitäten aus öffentlichen Schemas
❏ YAML-Konfiguration
❏ Schema.org
40. Wrapup
Perfekt für entitätenbasierte APIs
JSON-LD out of the box
Automatische Dokumentation & Clients
Perfekt in Symfony integriert
Killerfeatures per Annotation aktivierbar
GraphQL!
41. Thank you o/
Stefan Adolf
Turbine Kreuzberg
@stadolf
@elmariachi111
https://github.com/elmariachi111/apiplatform-demo/