Creating hypermedia APIs in a few minutes using the API Platform framework

Les-Tilleuls.coop
Les-Tilleuls.coopCEO at Les-Tilleuls.coop, freelance software architect
API PLATFORM
The PHP framework to build
modern web APIs.
Kévin Dunglas
Founder of Les-Tilleuls.coop
Symfony Core Team member
API Platform creator
Teacher at the University of Lille 1
@dunglas
Les-Tilleuls.coop
Self-managed company since 2011
100% owned by employees
All benefits are equitably shared between employees
18 people, 137% growth in 2015
We are hiring! => jobs@les-tilleuls.coop
The Promise
Support for modern and future formats
Batteries included: pagination, filtering, auth (JWT, OAuth),
HTTP Cache, CORS…
UI and automatic documentation (Swagger)
Extensible, overridable, customizable
A working API in a few minutes
API: State of the Art
HTTP + REST + JSON
Works easily with all programming languages, on every
platforms
Lightweight (= fast)
Stateless (= scale)
Easy to cache (= faster)
High quality tooling (cURL, Varnish…)
REST: a Pattern, Not a
Format
1 project ~= 1 different implementation
Tedious to create: pagination, filtering, validation, caching,
content negotiation, CORS, data interoperability…
Hard to reuse server-side tooling (1 API per project)
Hard to reuse client-side tooling (1 client per API)
Hard to query and aggregate data from different sources
Credit: Martin Fowler
http://martinfowler.com/articles/richardsonMaturityModel.html
HATEOAS / Linked Data
Hypermedia: IRIs (e.g. URLs) as identifiers
Ability to reference external data (like hypertext links)
Hypermedia controls (pagination, filtering…)
The road to better server-side tooling and generic clients
Hypermedia as the Engine of Application State
Creating hypermedia APIs in a few minutes using the API Platform framework
Standards Please!
Swagger / OpenAPI
Describe only I/O formats and available operations for an
API
Most popular way to describe APIs
Lot of tools available (UIs, code generators, validators…)
Open standard (but not endorsed by the W3C)
Not designed for HATEOAS APIs
JSON-LD
Standard: W3C recommandation (since 2014)
Easy to use: looks like a typical JSON document
Already chosen by Google, BBC, Microsoft, US gov...
Compliant with technologies of the semantic web: RDF,
SPARQL, triple store...
JSON for Linked Data
Schema.org
Large set of elements: people, creative works, events,
products, chemicals...
Created (and understood by) Google, Bing, Yahoo! et Yandex
Massively used, and hosted by the W3C (Web schemas
group)
Supports HTML’s microdata, RDFa and JSON-LD
Open vocabulary for data interoperability at web scale
Extension mechanism, compatible with proprietary/custom
vocabularies (yours)
Hydra
Write support (POST, PUT, PATCH…)
Make APIs auto-discoverable (all available operations are
documented)
A standard for describing collections, paginations, filters,
errors…
Draft W3C (Work In Progress)
Describe REST APIs in JSON-LD
Creating hypermedia APIs in a few minutes using the API Platform framework
Creating hypermedia APIs in a few minutes using the API Platform framework
Getting Started with
API Platform
A framework for the new web.
The Promise
Support for modern and future formats (JSON-LD,
Hydra, HAL, schema.org, API+Problem…)
Batteries included: pagination, filtering, auth (JWT, OAuth),
HTTP Cache, CORS…
Awesome UI and automatic documentation (Swagger)
Extensible, overridable, customizable
A working API in a few minutes
Install
Get Docker
If you don’t already have it…
Install
Start the LAMP stack (PHP7, Apache and MySQL)
$ docker-compose up
# Create the database
$ docker-compose exec web bin/console doctrine:schema:create
Go to api-platform.com then click « Download »
Done! Browse http://localhost.
Creating hypermedia APIs in a few minutes using the API Platform framework
It’s Symfony…
Configured with the most popular libraries
for APIs
Compatible with all existing bundles
Use Doctrine ORM by default (but you can
use the persistence system you want)
Symfony full stack application
…with something more
Create your Own
Data Model
Write some PHPDoc (optional)
Add the @ApiResource annotation
Map its properties using the
Doctrine ORM
Update the database schema
$ docker-compose run web bin/console
doctrine:schema:update --force
Create a Plain Old PHP Object
Your 1st API
Platform App is Up
and Running!
Creating hypermedia APIs in a few minutes using the API Platform framework
Out of the Box Features
JSON-LD + Hydra formats
Swagger documentation
Fully featured UI (working for all URLs of the API)
Create (POST), Retrieve (GET item and lists), Update
(PUT) and Delete (DELETE) resources
Pagination for lists (30 items per page), fully configurable
Add
validation rules
Many validation constraints available
Ability to create custom constraints
Use the Symfony Validator
component
Creating hypermedia APIs in a few minutes using the API Platform framework
The Schema Generator
Pick an existing data model from (resources and properties) from
schema.org:
docker-compose run web
vendor/bin/schema generate-types src/ app/config/schema.yml
The Schema Generator
The Schema Generator
PHP classes, properties, getters and setters (PSR compliant)
Doctrine ORM mapping (including relations and mapped superclasses)
Validation constraints
Full PHPDoc extracted from schema human-readable descriptions
Mapping with schema.org's IRIs
The generator uses schema.org data to automatically bootstrap:
Relations between classes (supported by the API system too)
Hypermedia relations
Creating hypermedia APIs in a few minutes using the API Platform framework
Embedded relations
Embedded relations
Content Negotiation
Adding a new format is as simple as creating a new
Symfony Normalizer for it
Built-in formats: JSON-LD, HAL, XML, YAML, CSV, JSON, HTML (UI)
To retrieve a resource in a given format: add an Accept
HTTP header or use the format name as file extension
Content Negotiation
Content Negotiation: HAL
Content Negotiation: XML
Filters
Register the filter service (built-in or custom):
Map the filter to the resource
Filters
The Event System
Events
There is Much More to See
Platform
A Growing Community
100+ awesome contributors (code and docs)
1.2k stars on GitHub
500+ followers on Twitter
Next Big Things (v2.1)
JSONAPI support
GraphQL support
Native MongoDB support
Your contribution?
Thanks!
Any questions?
api-platform/api-platform @ApiPlatform
https://api-platform.com
1 of 49

Recommended

API Platform: Full Stack Framework Resurrection by
API Platform: Full Stack Framework ResurrectionAPI Platform: Full Stack Framework Resurrection
API Platform: Full Stack Framework ResurrectionLes-Tilleuls.coop
13K views87 slides
API Platform and Symfony: a Framework for API-driven Projects by
API Platform and Symfony: a Framework for API-driven ProjectsAPI Platform and Symfony: a Framework for API-driven Projects
API Platform and Symfony: a Framework for API-driven ProjectsLes-Tilleuls.coop
20.6K views80 slides
API Platform: A Framework for API-driven Projects by
API Platform: A Framework for API-driven ProjectsAPI Platform: A Framework for API-driven Projects
API Platform: A Framework for API-driven ProjectsLes-Tilleuls.coop
23.8K views72 slides
API Platform 2.1: when Symfony meets ReactJS (Symfony Live 2017) by
API Platform 2.1: when Symfony meets ReactJS (Symfony Live 2017)API Platform 2.1: when Symfony meets ReactJS (Symfony Live 2017)
API Platform 2.1: when Symfony meets ReactJS (Symfony Live 2017)Les-Tilleuls.coop
23.2K views99 slides
Symfony3 w duecie z Vue.js by
Symfony3 w duecie z Vue.jsSymfony3 w duecie z Vue.js
Symfony3 w duecie z Vue.jsX-Coding IT Studio
3.5K views25 slides
JWT - Sécurisez vos APIs by
JWT - Sécurisez vos APIsJWT - Sécurisez vos APIs
JWT - Sécurisez vos APIsAndré Tapia
1.6K views77 slides

More Related Content

What's hot

A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017 by
A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017
A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017Carlos Buenosvinos
3.4K views57 slides
Building APIs in an easy way using API Platform by
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
293 views90 slides
Webpack Encore Symfony Live 2017 San Francisco by
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoRyan Weaver
2.8K views94 slides
Full Stack Scala by
Full Stack ScalaFull Stack Scala
Full Stack ScalaRamnivas Laddad
8.6K views89 slides
Laravel 5 Annotations: RESTful API routing by
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingChristopher Pecoraro
17.9K views57 slides
Prototyping applications with heroku and elasticsearch by
 Prototyping applications with heroku and elasticsearch Prototyping applications with heroku and elasticsearch
Prototyping applications with heroku and elasticsearchprotofy
1.2K views45 slides

What's hot(20)

A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017 by Carlos Buenosvinos
A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017
A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017
Carlos Buenosvinos3.4K views
Webpack Encore Symfony Live 2017 San Francisco by Ryan Weaver
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
Ryan Weaver2.8K views
Prototyping applications with heroku and elasticsearch by protofy
 Prototyping applications with heroku and elasticsearch Prototyping applications with heroku and elasticsearch
Prototyping applications with heroku and elasticsearch
protofy1.2K views
How to create aws s3 bucket using terraform by Katy Slemon
How to create aws s3 bucket using terraformHow to create aws s3 bucket using terraform
How to create aws s3 bucket using terraform
Katy Slemon188 views
Deployment and Management on AWS:
 A Deep Dive on Options and Tools by Danilo Poccia
Deployment and Management on AWS:
 A Deep Dive on Options and ToolsDeployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Danilo Poccia1.7K views
Introduction to laravel framework by Ahmad Fatoni
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
Ahmad Fatoni517 views
Introduction to REST and the Restlet Framework by Philip Johnson
Introduction to REST and the Restlet FrameworkIntroduction to REST and the Restlet Framework
Introduction to REST and the Restlet Framework
Philip Johnson3.9K views
Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour L... by Corley S.r.l.
Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour L...Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour L...
Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour L...
Corley S.r.l.6.3K views
Unleash the power of HTTP with ASP.NET Web API by Filip W
Unleash the power of HTTP with ASP.NET Web APIUnleash the power of HTTP with ASP.NET Web API
Unleash the power of HTTP with ASP.NET Web API
Filip W2.5K views
Aws ebs snapshot with iam cross account access by Naoya Hashimoto
Aws ebs snapshot with iam cross account accessAws ebs snapshot with iam cross account access
Aws ebs snapshot with iam cross account access
Naoya Hashimoto4.8K views
PHP konferencija - Microsoft by nusmas
PHP konferencija - MicrosoftPHP konferencija - Microsoft
PHP konferencija - Microsoft
nusmas931 views
Infrastructure as code with Amazon Web Services by Julien SIMON
Infrastructure as code with Amazon Web ServicesInfrastructure as code with Amazon Web Services
Infrastructure as code with Amazon Web Services
Julien SIMON2.7K views
State of integration with Apache Camel (ApacheCon 2019) by Claus Ibsen
State of integration with Apache Camel (ApacheCon 2019)State of integration with Apache Camel (ApacheCon 2019)
State of integration with Apache Camel (ApacheCon 2019)
Claus Ibsen2.6K views

Similar to Creating hypermedia APIs in a few minutes using the API Platform framework

UIT: Our Skills by
UIT: Our SkillsUIT: Our Skills
UIT: Our Skillsuitpramati
348 views13 slides
Angular jS Introduction by Google by
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by GoogleASG
94 views147 slides
Students of Navgujarat College of Computer Applications, Ahmedabad felt excit... by
Students of Navgujarat College of Computer Applications, Ahmedabad felt excit...Students of Navgujarat College of Computer Applications, Ahmedabad felt excit...
Students of Navgujarat College of Computer Applications, Ahmedabad felt excit...cresco
1.8K views22 slides
Advanced JavaScript by
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScriptMahmoud Tolba
2.1K views40 slides
A high profile project with Symfony and API Platform: beIN SPORTS by
A high profile project with Symfony and API Platform: beIN SPORTSA high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTSSmile I.T is open
61K views45 slides
Structured Dynamics' Semantic Technologies Product Stack by
Structured Dynamics' Semantic Technologies Product StackStructured Dynamics' Semantic Technologies Product Stack
Structured Dynamics' Semantic Technologies Product StackMike Bergman
2K views53 slides

Similar to Creating hypermedia APIs in a few minutes using the API Platform framework(20)

UIT: Our Skills by uitpramati
UIT: Our SkillsUIT: Our Skills
UIT: Our Skills
uitpramati348 views
Angular jS Introduction by Google by ASG
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
ASG94 views
Students of Navgujarat College of Computer Applications, Ahmedabad felt excit... by cresco
Students of Navgujarat College of Computer Applications, Ahmedabad felt excit...Students of Navgujarat College of Computer Applications, Ahmedabad felt excit...
Students of Navgujarat College of Computer Applications, Ahmedabad felt excit...
cresco1.8K views
A high profile project with Symfony and API Platform: beIN SPORTS by Smile I.T is open
A high profile project with Symfony and API Platform: beIN SPORTSA high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTS
Smile I.T is open61K views
Structured Dynamics' Semantic Technologies Product Stack by Mike Bergman
Structured Dynamics' Semantic Technologies Product StackStructured Dynamics' Semantic Technologies Product Stack
Structured Dynamics' Semantic Technologies Product Stack
Mike Bergman2K views
Building A Platform From Open Source At Yahoo by Dustin Whittle
Building A Platform From Open Source At YahooBuilding A Platform From Open Source At Yahoo
Building A Platform From Open Source At Yahoo
Dustin Whittle8.1K views
Technology Stack Discussion by Zaiyang Li
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
Zaiyang Li586 views
Programming With Amazon, Google, And E Bay by Phi Jack
Programming With Amazon, Google, And E BayProgramming With Amazon, Google, And E Bay
Programming With Amazon, Google, And E Bay
Phi Jack1.1K views
Creating Restful Web Services with restish by Grig Gheorghiu
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restish
Grig Gheorghiu4.2K views
Web 2.0 Mimbar Ilmiah by Soetam Rizky
Web 2.0 Mimbar IlmiahWeb 2.0 Mimbar Ilmiah
Web 2.0 Mimbar Ilmiah
Soetam Rizky517 views
Web technologies lesson 1 by nhepner
Web technologies   lesson 1Web technologies   lesson 1
Web technologies lesson 1
nhepner7.3K views
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ... by Vlad Savitsky
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Vlad Savitsky1.3K views
David_Thomas_Resume_Software_08_29_16 by Dave Thomas
David_Thomas_Resume_Software_08_29_16David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16
Dave Thomas416 views
Internet Explorer 8 by David Chou
Internet Explorer 8Internet Explorer 8
Internet Explorer 8
David Chou3.2K views
Leveraging Hadoop in Polyglot Architectures by Thanigai Vellore
Leveraging Hadoop in Polyglot ArchitecturesLeveraging Hadoop in Polyglot Architectures
Leveraging Hadoop in Polyglot Architectures
Thanigai Vellore3K views
Azure Platform by Wes Yanaga
Azure Platform Azure Platform
Azure Platform
Wes Yanaga2.1K views

More from Les-Tilleuls.coop

Symfony on steroids
: Vue.js, Mercure, Panther by
Symfony on steroids
: Vue.js, Mercure, PantherSymfony on steroids
: Vue.js, Mercure, Panther
Symfony on steroids
: Vue.js, Mercure, PantherLes-Tilleuls.coop
46K views56 slides
Official "push" and real-time capabilities for Symfony and API Platform (Merc... by
Official "push" and real-time capabilities for Symfony and API Platform (Merc...Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...Les-Tilleuls.coop
53.9K views62 slides
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and... by
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...Les-Tilleuls.coop
43.5K views55 slides
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl... by
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...Les-Tilleuls.coop
35.7K views59 slides
Panther: test your Symfony apps with real web browsers by
Panther: test your Symfony apps with real web browsersPanther: test your Symfony apps with real web browsers
Panther: test your Symfony apps with real web browsersLes-Tilleuls.coop
28.1K views57 slides
Symfony 2 : Performances et Optimisations by
Symfony 2 : Performances et OptimisationsSymfony 2 : Performances et Optimisations
Symfony 2 : Performances et OptimisationsLes-Tilleuls.coop
14.3K views20 slides

More from Les-Tilleuls.coop(11)

Symfony on steroids
: Vue.js, Mercure, Panther by Les-Tilleuls.coop
Symfony on steroids
: Vue.js, Mercure, PantherSymfony on steroids
: Vue.js, Mercure, Panther
Symfony on steroids
: Vue.js, Mercure, Panther
Les-Tilleuls.coop46K views
Official "push" and real-time capabilities for Symfony and API Platform (Merc... by Les-Tilleuls.coop
Official "push" and real-time capabilities for Symfony and API Platform (Merc...Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Les-Tilleuls.coop53.9K views
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and... by Les-Tilleuls.coop
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
Les-Tilleuls.coop43.5K views
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl... by Les-Tilleuls.coop
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
Les-Tilleuls.coop35.7K views
Panther: test your Symfony apps with real web browsers by Les-Tilleuls.coop
Panther: test your Symfony apps with real web browsersPanther: test your Symfony apps with real web browsers
Panther: test your Symfony apps with real web browsers
Les-Tilleuls.coop28.1K views
Symfony 2 : Performances et Optimisations by Les-Tilleuls.coop
Symfony 2 : Performances et OptimisationsSymfony 2 : Performances et Optimisations
Symfony 2 : Performances et Optimisations
Les-Tilleuls.coop14.3K views
Diaporama du sfPot Lillois du 20 mars 2014 by Les-Tilleuls.coop
Diaporama du sfPot Lillois du 20 mars 2014Diaporama du sfPot Lillois du 20 mars 2014
Diaporama du sfPot Lillois du 20 mars 2014
Les-Tilleuls.coop4.4K views
Workshop HTML5 : référencement grâce à la sémantique by Les-Tilleuls.coop
Workshop HTML5 : référencement grâce à la sémantiqueWorkshop HTML5 : référencement grâce à la sémantique
Workshop HTML5 : référencement grâce à la sémantique
Les-Tilleuls.coop2.1K views

Recently uploaded

SUGCON ANZ Presentation V2.1 Final.pptx by
SUGCON ANZ Presentation V2.1 Final.pptxSUGCON ANZ Presentation V2.1 Final.pptx
SUGCON ANZ Presentation V2.1 Final.pptxJack Spektor
22 views34 slides
Copilot Prompting Toolkit_All Resources.pdf by
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdfRiccardo Zamana
8 views4 slides
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...Deltares
14 views23 slides
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...sparkfabrik
5 views46 slides
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema by
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - GeertsemaDSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - GeertsemaDeltares
17 views13 slides
WebAssembly by
WebAssemblyWebAssembly
WebAssemblyJens Siebert
48 views18 slides

Recently uploaded(20)

SUGCON ANZ Presentation V2.1 Final.pptx by Jack Spektor
SUGCON ANZ Presentation V2.1 Final.pptxSUGCON ANZ Presentation V2.1 Final.pptx
SUGCON ANZ Presentation V2.1 Final.pptx
Jack Spektor22 views
Copilot Prompting Toolkit_All Resources.pdf by Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana8 views
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by Deltares
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
Deltares14 views
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik5 views
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - GeertsemaDSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
Deltares17 views
Quality Engineer: A Day in the Life by John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino6 views
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares17 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller38 views
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs by Deltares
DSD-INT 2023 The Danube Hazardous Substances Model - KovacsDSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
Deltares8 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta6 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri825 views
DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut... by Deltares
DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut...DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut...
DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut...
Deltares7 views

Creating hypermedia APIs in a few minutes using the API Platform framework

  • 1. API PLATFORM The PHP framework to build modern web APIs.
  • 2. Kévin Dunglas Founder of Les-Tilleuls.coop Symfony Core Team member API Platform creator Teacher at the University of Lille 1 @dunglas
  • 3. Les-Tilleuls.coop Self-managed company since 2011 100% owned by employees All benefits are equitably shared between employees 18 people, 137% growth in 2015 We are hiring! => jobs@les-tilleuls.coop
  • 4. The Promise Support for modern and future formats Batteries included: pagination, filtering, auth (JWT, OAuth), HTTP Cache, CORS… UI and automatic documentation (Swagger) Extensible, overridable, customizable A working API in a few minutes
  • 5. API: State of the Art
  • 6. HTTP + REST + JSON Works easily with all programming languages, on every platforms Lightweight (= fast) Stateless (= scale) Easy to cache (= faster) High quality tooling (cURL, Varnish…)
  • 7. REST: a Pattern, Not a Format 1 project ~= 1 different implementation Tedious to create: pagination, filtering, validation, caching, content negotiation, CORS, data interoperability… Hard to reuse server-side tooling (1 API per project) Hard to reuse client-side tooling (1 client per API) Hard to query and aggregate data from different sources
  • 9. HATEOAS / Linked Data Hypermedia: IRIs (e.g. URLs) as identifiers Ability to reference external data (like hypertext links) Hypermedia controls (pagination, filtering…) The road to better server-side tooling and generic clients Hypermedia as the Engine of Application State
  • 12. Swagger / OpenAPI Describe only I/O formats and available operations for an API Most popular way to describe APIs Lot of tools available (UIs, code generators, validators…) Open standard (but not endorsed by the W3C) Not designed for HATEOAS APIs
  • 13. JSON-LD Standard: W3C recommandation (since 2014) Easy to use: looks like a typical JSON document Already chosen by Google, BBC, Microsoft, US gov... Compliant with technologies of the semantic web: RDF, SPARQL, triple store... JSON for Linked Data
  • 14. Schema.org Large set of elements: people, creative works, events, products, chemicals... Created (and understood by) Google, Bing, Yahoo! et Yandex Massively used, and hosted by the W3C (Web schemas group) Supports HTML’s microdata, RDFa and JSON-LD Open vocabulary for data interoperability at web scale Extension mechanism, compatible with proprietary/custom vocabularies (yours)
  • 15. Hydra Write support (POST, PUT, PATCH…) Make APIs auto-discoverable (all available operations are documented) A standard for describing collections, paginations, filters, errors… Draft W3C (Work In Progress) Describe REST APIs in JSON-LD
  • 18. Getting Started with API Platform A framework for the new web.
  • 19. The Promise Support for modern and future formats (JSON-LD, Hydra, HAL, schema.org, API+Problem…) Batteries included: pagination, filtering, auth (JWT, OAuth), HTTP Cache, CORS… Awesome UI and automatic documentation (Swagger) Extensible, overridable, customizable A working API in a few minutes
  • 20. Install Get Docker If you don’t already have it…
  • 21. Install Start the LAMP stack (PHP7, Apache and MySQL) $ docker-compose up # Create the database $ docker-compose exec web bin/console doctrine:schema:create Go to api-platform.com then click « Download » Done! Browse http://localhost.
  • 23. It’s Symfony… Configured with the most popular libraries for APIs Compatible with all existing bundles Use Doctrine ORM by default (but you can use the persistence system you want) Symfony full stack application …with something more
  • 24. Create your Own Data Model Write some PHPDoc (optional) Add the @ApiResource annotation Map its properties using the Doctrine ORM Update the database schema $ docker-compose run web bin/console doctrine:schema:update --force Create a Plain Old PHP Object
  • 25. Your 1st API Platform App is Up and Running!
  • 27. Out of the Box Features JSON-LD + Hydra formats Swagger documentation Fully featured UI (working for all URLs of the API) Create (POST), Retrieve (GET item and lists), Update (PUT) and Delete (DELETE) resources Pagination for lists (30 items per page), fully configurable
  • 28. Add validation rules Many validation constraints available Ability to create custom constraints Use the Symfony Validator component
  • 30. The Schema Generator Pick an existing data model from (resources and properties) from schema.org: docker-compose run web vendor/bin/schema generate-types src/ app/config/schema.yml
  • 32. The Schema Generator PHP classes, properties, getters and setters (PSR compliant) Doctrine ORM mapping (including relations and mapped superclasses) Validation constraints Full PHPDoc extracted from schema human-readable descriptions Mapping with schema.org's IRIs The generator uses schema.org data to automatically bootstrap: Relations between classes (supported by the API system too)
  • 37. Content Negotiation Adding a new format is as simple as creating a new Symfony Normalizer for it Built-in formats: JSON-LD, HAL, XML, YAML, CSV, JSON, HTML (UI) To retrieve a resource in a given format: add an Accept HTTP header or use the format name as file extension
  • 41. Filters Register the filter service (built-in or custom): Map the filter to the resource
  • 45. There is Much More to See
  • 47. A Growing Community 100+ awesome contributors (code and docs) 1.2k stars on GitHub 500+ followers on Twitter
  • 48. Next Big Things (v2.1) JSONAPI support GraphQL support Native MongoDB support Your contribution?