Your SlideShare is downloading. ×
0
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

nguyenhainhathuy-building-restful-web-service

799

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
799
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. BuildingRESTful Web ServiceWith PHPHuy Nguyen - huy@byhuy.com
  • 2.  REST and RESTful web service Building a RESTful framework with PHP
  • 3. REpresentational State Transfer An architecture not a protocol or a standard Resource Oriented Approach World Wide Web is the key example
  • 4. What is a RESTful web service? A web site for Machines!!!
  • 5. MIME typesGET POSTPUT DELETE HEAD supported OPTIONSResources URIs Its all about HTTP, dude!
  • 6. REST vs RPC ROA vs SOARESOURCES vs FUNCTIONS
  • 7. Flickr has a RESTful web service But its crap!!!!!!!
  • 8. This is RESTful:http://feeds.feedburner.com/Geshansblogand this is not:http://api.flickr.com/services/rest/?method=flickr.test.echo&name=value
  • 9. RESTful Web Protocols Syndication protocols (RSS, Atom Feed) Atom Publishing Protocol RDF and OWL OpenID Single Sign-on Standard Googles OpenSocial Protocol Amazons S3 Protocol ...
  • 10. Now lets talk about PHP... and how it supports REST
  • 11. $_SERVER Accept => $_SERVER[HTTP_ACCEPT]Request Method => $_SERVER[REQUEST_METHOD]
  • 12. $_POST and $_GETEveryone knows them!
  • 13. RAW POST/PUT REQUEST DATA?<?php// get RAW HTTP POST$rawData = file_get_contents(php://input);// but this wont work with enctype="multipart/form-data" :(
  • 14. Why is symfony not RESTful?because RESTful web service is about resources, not functions/actions
  • 15. My RESTful Framework Creating Resources Creating URIs Handling HTTP methods MIME-type support
  • 16. Resources As ControllersA resources is a class that handles HTTP methods
  • 17. /** * HTTP GET handler */ public function __handleGet() { // Not implemented $this->_response->setResponseCode(501); } /** * HTTP POST handler */ public function __handlePost() { // Not implemented $this->_response->setResponseCode(501); } /** * HTTP PUT handler */ public function __handlePut() { // Not implemented $this->_response->setResponseCode(501); }
  • 18. /** * HTTP DELETE handler */ public function __handleDelete() { // Not implemented $this->_response->setResponseCode(501); } /** * HTTP HEAD handler */ public function __handleHead() { // Not implemented $this->_response->setResponseCode(501); }
  • 19. Creating The URIs/blog/([a-zA-Z0-9]+)/? => blogResource
  • 20. Composite Resources Konstrukt Framework (konstrukt.dk)
  • 21. MIME Types & Multiple Views $_SERVER[HTTP_ACCEPT]text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  • 22. My framework is called Kao
  • 23. Thank you! I love PHP!
  • 24. Any Question?

×