Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MeetPHP # 13 - Can you finally rest

814 views

Published on

How to not ruin life of developers. About basic rules of RESTful API, documentation and tools.


Repo from live coding:
https://github.com/emgiezet/meetphp13-rest


Read More:
http://shishkin.github.io/presentations/rest/
http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http
http://martinfowler.com/articles/richardsonMaturityModel.html
http://timelessrepo.com/haters-gonna-hateoas
http://www.slideshare.net/kifahibrahim/symfony2-as-an-api
https://speakerdeck.com/gordalina/rest-apis-made-easy-with-symfony2

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

MeetPHP # 13 - Can you finally rest

  1. 1. Can you finally REST?! meet.php # 13 by: Max Małecki @emgiezet
  2. 2. Cool developers: ● Mobile developers ● Node.js developers ● Ruby developers
  3. 3. Can I be as cool as they are? You write APIs for them. Cool developers can't live without you!
  4. 4. 7 sins of your API ● What makes you uncool? ● Why „cool“ developers hates you?
  5. 5. 0. Lack of design
  6. 6. 1. Session Management ● RESTful – means stateless ● To authorize & authenticate use – oAuth v2 – Wsse
  7. 7. 2. Content type constraints GET /api/dogs.json – 200 GET /api/dogs.xml – 404 ● Retrun a response in a format defined in the headers of a request: GET /api/dogs/123 Accept: application/vnd.example+xml, application/xml, application/json Accept-Language: de, fr, en
  8. 8. 3. Api url's /api/dogs?id=123 ● Instead use uri templates /api/dogs/123 ● Get parameters are good for filtering /api/dogs?color=black
  9. 9. 3. Avoidance of HTTP Methods /api/dogs/show GET /api/dogs POST /api/dogs/api/dogs/new
  10. 10. 4. Complexity ● Make it simple and universal
  11. 11. 5. Lack of documentation ● If you got documentation in PDF, be sure that something is wrong.
  12. 12. 6. Api is not cacheable ● Do you know: – varnish? – haproxy? ● So design your API to be cacheable ● PHP is not super fast consider the CACHE!
  13. 13. Quick tips ● Test your API – TTD is not that hard. ● Make sandbox for vendor developers ● Please, oh please use serialization
  14. 14. Richardson REST maturity model ● Level 0 - Swamp of POX ● Level 1 - Resources ● Level 3 - Hypermedia controls● Level 2 - HTTP verbs
  15. 15. Richardson Model in Symfony2 ● Level 0 & Level 1 & Level 2: – FOSRestBundle – NelmioAPIDocBundle ● Authentication: – FOSOAuthServerBundle ● Level 3: – BazingaHateoasBundle
  16. 16. Live Code
  17. 17. You want that code?
  18. 18. Questions?
  19. 19. Want more? ● http://shishkin.github.io/presentations/rest/ ● http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-res t-or-http ● http://martinfowler.com/articles/richardsonMaturityModel.html ● http://timelessrepo.com/haters-gonna-hateoas ● http://www.slideshare.net/kifahibrahim/symfony2-as-an-api ● https://speakerdeck.com/gordalina/rest-apis-made-easy-with-symfony2
  20. 20. My Question: Explain the HATEOAS acronym Hypertext As The Engine Of Application State
  21. 21. Thank you! You're cool developer? Now you can finally REST!

×