SlideShare a Scribd company logo
1 of 49
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
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
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.
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!
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
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
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

More Related Content

What's hot

Unleash the power of HTTP with ASP.NET Web API
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 W
 

What's hot (20)

A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017
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
 
Building APIs in an easy way using API Platform
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 Platform
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
 
Full Stack Scala
Full Stack ScalaFull Stack Scala
Full Stack Scala
 
Laravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routing
 
Prototyping applications with heroku and elasticsearch
 Prototyping applications with heroku and elasticsearch Prototyping applications with heroku and elasticsearch
Prototyping applications with heroku and elasticsearch
 
How to create aws s3 bucket using terraform
How to create aws s3 bucket using terraformHow to create aws s3 bucket using terraform
How to create aws s3 bucket using terraform
 
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
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
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
Introduction to REST and the Restlet Framework
Introduction to REST and the Restlet FrameworkIntroduction to REST and the Restlet Framework
Introduction to REST and the Restlet Framework
 
Programming Amazon Web Services
Programming Amazon Web ServicesProgramming Amazon Web Services
Programming Amazon Web Services
 
Sun Web Server Brief
Sun Web Server BriefSun Web Server Brief
Sun Web Server Brief
 
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...
Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour L...
 
Unleash the power of HTTP with ASP.NET Web API
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
 
CloudStack S3
CloudStack S3CloudStack S3
CloudStack S3
 
Aws ebs snapshot with iam cross account access
Aws ebs snapshot with iam cross account accessAws ebs snapshot with iam cross account access
Aws ebs snapshot with iam cross account access
 
PHP konferencija - Microsoft
PHP konferencija - MicrosoftPHP konferencija - Microsoft
PHP konferencija - Microsoft
 
Infrastructure as code with Amazon Web Services
Infrastructure as code with Amazon Web ServicesInfrastructure as code with Amazon Web Services
Infrastructure as code with Amazon Web Services
 
State of integration with Apache Camel (ApacheCon 2019)
State of integration with Apache Camel (ApacheCon 2019)State of integration with Apache Camel (ApacheCon 2019)
State of integration with Apache Camel (ApacheCon 2019)
 

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

UIT: Our Skills
UIT: Our SkillsUIT: Our Skills
UIT: Our Skills
uitpramati
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
Zaiyang Li
 
Programming With Amazon, Google, And E Bay
Programming With Amazon, Google, And E BayProgramming With Amazon, Google, And E Bay
Programming With Amazon, Google, And E Bay
Phi Jack
 
Web 2.0 Mimbar Ilmiah
Web 2.0 Mimbar IlmiahWeb 2.0 Mimbar Ilmiah
Web 2.0 Mimbar Ilmiah
Soetam Rizky
 
Web technologies lesson 1
Web technologies   lesson 1Web technologies   lesson 1
Web technologies lesson 1
nhepner
 
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. ...
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Vlad Savitsky
 
David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16
Dave Thomas
 

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

UIT: Our Skills
UIT: Our SkillsUIT: Our Skills
UIT: Our Skills
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 
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...
Students of Navgujarat College of Computer Applications, Ahmedabad felt excit...
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
A high profile project with Symfony and API Platform: beIN SPORTS
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
 
Structured Dynamics' Semantic Technologies Product Stack
Structured Dynamics' Semantic Technologies Product StackStructured Dynamics' Semantic Technologies Product Stack
Structured Dynamics' Semantic Technologies Product Stack
 
Building A Platform From Open Source At Yahoo
Building A Platform From Open Source At YahooBuilding A Platform From Open Source At Yahoo
Building A Platform From Open Source At Yahoo
 
What is WebDAV - uploaded by Murali Krishna Nookella
What is WebDAV - uploaded by Murali Krishna NookellaWhat is WebDAV - uploaded by Murali Krishna Nookella
What is WebDAV - uploaded by Murali Krishna Nookella
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
 
Programming With Amazon, Google, And E Bay
Programming With Amazon, Google, And E BayProgramming With Amazon, Google, And E Bay
Programming With Amazon, Google, And E Bay
 
How To Implement a CMS
How To Implement a CMSHow To Implement a CMS
How To Implement a CMS
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restish
 
Web 2.0 Mimbar Ilmiah
Web 2.0 Mimbar IlmiahWeb 2.0 Mimbar Ilmiah
Web 2.0 Mimbar Ilmiah
 
Web technologies lesson 1
Web technologies   lesson 1Web technologies   lesson 1
Web technologies lesson 1
 
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. ...
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
 
Dspace 7 presentation
Dspace 7 presentationDspace 7 presentation
Dspace 7 presentation
 
David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16
 
Internet Explorer 8
Internet Explorer 8Internet Explorer 8
Internet Explorer 8
 
Leveraging Hadoop in Polyglot Architectures
Leveraging Hadoop in Polyglot ArchitecturesLeveraging Hadoop in Polyglot Architectures
Leveraging Hadoop in Polyglot Architectures
 
Azure Platform
Azure Platform Azure Platform
Azure Platform
 

More from 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...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Les-Tilleuls.coop
 

More from Les-Tilleuls.coop (11)

Symfony on steroids
: Vue.js, Mercure, Panther
Symfony on steroids
: Vue.js, Mercure, PantherSymfony on steroids
: Vue.js, Mercure, Panther
Symfony on steroids
: Vue.js, Mercure, Panther
 
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...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...
 
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...
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
 
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...
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
 
Panther: test your Symfony apps with real web browsers
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
 
Symfony 2 : Performances et Optimisations
Symfony 2 : Performances et OptimisationsSymfony 2 : Performances et Optimisations
Symfony 2 : Performances et Optimisations
 
Diaporama du sfPot Lillois du 20 mars 2014
Diaporama du sfPot Lillois du 20 mars 2014Diaporama du sfPot Lillois du 20 mars 2014
Diaporama du sfPot Lillois du 20 mars 2014
 
Workshop HTML5 : référencement grâce à la sémantique
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
 
Atelier #3 intégration html
Atelier #3 intégration htmlAtelier #3 intégration html
Atelier #3 intégration html
 
Atelier #2 initiation à css
Atelier #2 initiation à cssAtelier #2 initiation à css
Atelier #2 initiation à css
 
Atelier initiation au html5
Atelier initiation au html5Atelier initiation au html5
Atelier initiation au html5
 

Recently uploaded

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Recently uploaded (20)

WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 

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
  • 10.
  • 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
  • 16.
  • 17.
  • 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.
  • 22.
  • 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!
  • 26.
  • 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
  • 29.
  • 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)
  • 34.
  • 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?