Download - Symfony Camp 2013 UA RESTing with Symfony2
![Page 2: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/2.jpg)
Introduction to REpresentational State
Transfer
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 3: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/3.jpg)
REST Maturity Model
RESTing
http://martinfowler.com/articles/richardsonMaturityModel.html
Lukas Kahwe SmithSunday, October 27, 13
![Page 4: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/4.jpg)
Level 0: The Swamp of POX•HTTP as a tunneling mechanism•“Procedural” communication (RPC)•Single endpoint (per operation)
Lukas Kahwe Smith
RESTing
Sunday, October 27, 13
![Page 5: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/5.jpg)
Level 1: Resources•Individual resources, i.e. URIs•“Object orientated” communication
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 6: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/6.jpg)
Level 2: HTTP Verbs•Client uses specific HTTP method•Server uses HTTP status codes
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 7: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/7.jpg)
Level 2: HTTP Methods
RESTing
Lukas Kahwe Smith
Method Safe? (★) Idempotent? (✦)
GET Yes YesHEAD Yes YesPOST No NoPUT No Yes
DELETE No Yes.. No No
(★) cacheable (✦) result independent on # of executions
Sunday, October 27, 13
![Page 8: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/8.jpg)
RESTing
Lukas Kahwe Smith
Code range Description Example
1xx Information 100 - Continue2xx Successful 201 - Created
3xx Redirection 301 - Moved Permanently
4xx Client Error 404 - Not Found
5xx Server Error 501 - Not Implemented
Level 2: HTTP status codes
Sunday, October 27, 13
![Page 9: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/9.jpg)
Level 3: Hypermedia Control•Service discovery via link relations•ATOM, HAL, JSON-LD, IANA Link Rel
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 10: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/10.jpg)
RESTing
Hypertext As The Engine Of Application
State
Sunday, October 27, 13
![Page 11: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/11.jpg)
H A T E O A S
RESTing
Sunday, October 27, 13
![Page 12: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/12.jpg)
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
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 13: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/13.jpg)
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
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 14: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/14.jpg)
URIs
•Identifies a resource•Independent of a specific format•URI “file extensions” != RESTful
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 15: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/15.jpg)
Media Types•Identifies a representation format•Custom types «application/vnd.»
RESTing
Lukas Kahwe Smith
Header Description
Content-Type HTTP message format
Accept HTTP response format preference
Accept-Encoding, Accept-Language, ..
HTTP response preference
Sunday, October 27, 13
![Page 16: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/16.jpg)
Content Type Negotiation
•Finding appropriate response format•No standardized algorithm available•Apache mod_negotiation algorithm is well documented
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 17: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/17.jpg)
Content Type NegotiationAccept: application/json,application/xml;q=0.9,text/html;q=0.8,*/*;q=0.7
RESTing
Lukas Kahwe Smith
Priority Description
q=0.9 application/json or application/xml
q=0.8 text/html
q=0.7 */* (anything)
Sunday, October 27, 13
![Page 18: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/18.jpg)
RESTing with Symfony2
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 19: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/19.jpg)
Bundles for a REST Server
•FOSRestBundle•JMSSerializerBundle•NelmioApiDocBundle•BazingaHateoasBundle ( FSCHateoasBundle )
•TemplatedUriBundle•LiipCacheControlBundle•FOSOAuthServerBundle
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 20: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/20.jpg)
Bundles for a REST Client
•FOSRestBundle•JMSSerializerBundle•HWIOAuthBundle•MisdGuzzleBundle
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 21: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/21.jpg)
Demo Time!
https://github.com/lsmith77/symfony-rest-edition/tree/2.3
RESTing
Lukas Kahwe SmithSunday, October 27, 13
![Page 22: Symfony Camp 2013 UA RESTing with Symfony2](https://reader033.vdocument.in/reader033/viewer/2022051210/54c69a9d4a79593b258b463b/html5/thumbnails/22.jpg)
Further reading•http://martinfowler.com/articles/richardsonMaturityModel.html•http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven•http://www.slideshare.net/Wombert/designing-http-interfaces-and-restful-web-services-dpc2012-20120608•http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right-way/•http://knpuniversity.com/blog/what-the-rest•http://knpuniversity.com/blog/rest-revisited
RESTing
Lukas Kahwe SmithSunday, October 27, 13