SlideShare a Scribd company logo
1 of 22
Download to read offline
RESTing with Symfony2
Lukas Kahwe Smith | Liip AG
smith@pooteeweet.org |
@lsmith

Sunday, October 27, 13
RESTing

Introduction to
REpresentational State
Transfer

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

REST Maturity Model

http://martinfowler.com/articles/richardsonMaturityModel.html
Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Level 0: The Swamp of POX
•HTTP as a tunneling mechanism
•“Procedural” communication (RPC)
•Single endpoint (per operation)

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Level 1: Resources
•Individual resources, i.e. URIs
•“Object orientated” communication

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Level 2: HTTP Verbs
•Client uses specific HTTP method
•Server uses HTTP status codes

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Level 2: HTTP Methods
Method
GET
HEAD
POST
PUT
DELETE
..

Safe? (★)
Yes
Yes
No
No
No
No

Idempotent? (✦)
Yes
Yes
No
Yes
Yes
No

(★) cacheable (✦) result independent on # of executions
Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Level 2: HTTP status codes
Code range Description
1xx
Information
2xx
Successful
3xx

Redirection

4xx

Client Error

5xx

Server Error

Example
100 - Continue
201 - Created
301 - Moved
Permanently
404 - Not Found
501 - Not
Implemented

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Level 3: Hypermedia Control
•Service discovery via link relations
•ATOM, HAL, JSON-LD, IANA Link Rel

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Hypertext As The
Engine Of Application
State

Sunday, October 27, 13
RESTing

HATEOAS

Sunday, October 27, 13
RESTing

RMM vs REST vs real life
•RMM only covers a subset of REST
•RMM Level 2 is what most developer
think is sufficient for REST
•RMM Level 3 is a REST precondition
•RMM Level 3 makes URI formatting
matter less
Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

RMM vs REST vs real life
•REST is protocol independent
•Few clients are prepared to leverage
HATEOAS enabled REST APIs
•Browsers are bad REST clients

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

URIs
•Identifies a resource
•Independent of a specific format
•URI “file extensions” != RESTful

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Media Types
•Identifies a representation format
•Custom types «application/vnd.»
Header

Description

Content-Type

HTTP message format

Accept
Accept-Encoding,
Accept-Language, ..

HTTP response format
preference
HTTP response
preference
Lukas Kahwe Smith

Sunday, October 27, 13
RESTing

Content Type Negotiation
•Finding appropriate response format
•No standardized algorithm available
•Apache mod_negotiation algorithm
is well documented

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Content Type Negotiation
Accept: application/json,application/
xml;q=0.9,text/html;q=0.8,*/*;q=0.7
Priority

Description

q=0.9

application/json
or application/xml

q=0.8

text/html

q=0.7

*/* (anything)

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

RESTing with Symfony2

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Bundles for a REST Server
•FOSRestBundle
•JMSSerializerBundle
•NelmioApiDocBundle
•BazingaHateoasBundle ( FSCHateoasBundle )
•TemplatedUriBundle
•LiipCacheControlBundle
•FOSOAuthServerBundle
Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Bundles for a REST Client
•FOSRestBundle
•JMSSerializerBundle
•HWIOAuthBundle
•MisdGuzzleBundle

Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Demo Time!
https://github.com/lsmith77/
symfony-rest-edition/tree/2.3
Lukas Kahwe Smith
Sunday, October 27, 13
RESTing

Further reading
•http://martinfowler.com/articles/
richardsonMaturityModel.html
•http://roy.gbiv.com/untangled/2008/rest-apismust-be-hypertext-driven
•http://www.slideshare.net/Wombert/
designing-http-interfaces-and-restful-webservices-dpc2012-20120608
•http://williamdurand.fr/2012/08/02/rest-apiswith-symfony2-the-right-way/
•http://knpuniversity.com/blog/what-the-rest
•http://knpuniversity.com/blog/rest-revisited
Lukas Kahwe Smith
Sunday, October 27, 13

More Related Content

What's hot

NATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATSNATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATS
Raül Pérez
 
OpenStack Swift overview oscon2011
OpenStack Swift overview oscon2011OpenStack Swift overview oscon2011
OpenStack Swift overview oscon2011
Open Stack
 

What's hot (16)

Openstack Swift Introduction
Openstack Swift IntroductionOpenstack Swift Introduction
Openstack Swift Introduction
 
Infinite Topic Backlogs with Apache Pulsar
Infinite Topic Backlogs with Apache PulsarInfinite Topic Backlogs with Apache Pulsar
Infinite Topic Backlogs with Apache Pulsar
 
Micro on NATS - Microservices with Messaging
Micro on NATS - Microservices with MessagingMicro on NATS - Microservices with Messaging
Micro on NATS - Microservices with Messaging
 
ThingMonk 2014: How To Improve On MQTT 3.1.1
ThingMonk 2014: How To Improve On MQTT 3.1.1ThingMonk 2014: How To Improve On MQTT 3.1.1
ThingMonk 2014: How To Improve On MQTT 3.1.1
 
NATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATSNATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATS
 
Introduction to Microservices Patterns
Introduction to Microservices PatternsIntroduction to Microservices Patterns
Introduction to Microservices Patterns
 
Cloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical OverviewCloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical Overview
 
Building Linux IPv6 DNS Server (Third Review)
Building Linux IPv6 DNS Server (Third Review)Building Linux IPv6 DNS Server (Third Review)
Building Linux IPv6 DNS Server (Third Review)
 
Communicating on the web
Communicating on the webCommunicating on the web
Communicating on the web
 
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
DockerCon Live 2020 - Securing Your Containerized Application with NGINXDockerCon Live 2020 - Securing Your Containerized Application with NGINX
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
 
Fast SOA with Apache Synapse
Fast SOA with Apache SynapseFast SOA with Apache Synapse
Fast SOA with Apache Synapse
 
Http/2 lightning
Http/2   lightningHttp/2   lightning
Http/2 lightning
 
What’s New in NGINX Ingress Controller for Kubernetes Release 1.5.0
What’s New in NGINX Ingress Controller for Kubernetes Release 1.5.0What’s New in NGINX Ingress Controller for Kubernetes Release 1.5.0
What’s New in NGINX Ingress Controller for Kubernetes Release 1.5.0
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST Microservice
 
Analyzing NGINX Logs with Datadog
Analyzing NGINX Logs with DatadogAnalyzing NGINX Logs with Datadog
Analyzing NGINX Logs with Datadog
 
OpenStack Swift overview oscon2011
OpenStack Swift overview oscon2011OpenStack Swift overview oscon2011
OpenStack Swift overview oscon2011
 

Viewers also liked

Game Changing Dependency Management
Game Changing Dependency ManagementGame Changing Dependency Management
Game Changing Dependency Management
Jeremy Kendall
 

Viewers also liked (8)

Game Changing Dependency Management
Game Changing Dependency ManagementGame Changing Dependency Management
Game Changing Dependency Management
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Laravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routing
 
L'intégration d'e-mails responsive
L'intégration d'e-mails responsiveL'intégration d'e-mails responsive
L'intégration d'e-mails responsive
 
Effective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 DevelopersEffective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 Developers
 
Docker for PHP Developers - Jetbrains
Docker for PHP Developers - JetbrainsDocker for PHP Developers - Jetbrains
Docker for PHP Developers - Jetbrains
 
Rock-solid Magento Deployments (and Development)
Rock-solid Magento Deployments (and Development)Rock-solid Magento Deployments (and Development)
Rock-solid Magento Deployments (and Development)
 
Leaky Bucket & Tocken Bucket - Traffic shaping
Leaky Bucket & Tocken Bucket - Traffic shapingLeaky Bucket & Tocken Bucket - Traffic shaping
Leaky Bucket & Tocken Bucket - Traffic shaping
 

Similar to Symfony Camp 2013 UA RESTing with Symfony2

REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
Jeelani Shaik
 

Similar to Symfony Camp 2013 UA RESTing with Symfony2 (20)

Resting on your laurels will get you powned
Resting on your laurels will get you pownedResting on your laurels will get you powned
Resting on your laurels will get you powned
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 
Rest and Microservices at the Las Vegas Dot Net Group
Rest and Microservices at the Las Vegas Dot Net GroupRest and Microservices at the Las Vegas Dot Net Group
Rest and Microservices at the Las Vegas Dot Net Group
 
REST API in Salesforce
REST API in SalesforceREST API in Salesforce
REST API in Salesforce
 
REST API in Salesforce
REST API in SalesforceREST API in Salesforce
REST API in Salesforce
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using Php
 
REST and Microservices
REST and MicroservicesREST and Microservices
REST and Microservices
 
REST Basics
REST BasicsREST Basics
REST Basics
 
ROA.ppt
ROA.pptROA.ppt
ROA.ppt
 
Grokking the REST Architectural Style
Grokking the REST Architectural StyleGrokking the REST Architectural Style
Grokking the REST Architectural Style
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with OData
 
RESTful application with JAX-RS and how to expose and test them
RESTful application with JAX-RS and how to expose and test themRESTful application with JAX-RS and how to expose and test them
RESTful application with JAX-RS and how to expose and test them
 
REST APIs
REST APIsREST APIs
REST APIs
 
You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!
 
Unerstanding and Using RESTful APIs
Unerstanding and Using RESTful APIsUnerstanding and Using RESTful APIs
Unerstanding and Using RESTful APIs
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Together Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with HypermediaTogether Cheerfully to Walk with Hypermedia
Together Cheerfully to Walk with Hypermedia
 
Api Design
Api DesignApi Design
Api Design
 
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Recently uploaded (20)

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 

Symfony Camp 2013 UA RESTing with Symfony2