SlideShare a Scribd company logo
ReST (Introduction)


 3rd Meetup PHP Indonesia

         6 April 2013
          Surabaya



       by Glend Maatita
ReST example (Twitter)
ReST example (Facebook)
ReST - History

●   Representational State Transfer


●   ReST was re-DISCOVER-ed by Roy Fielding


●   Doesnt require any external library


●   Tightly bond with HTTP
ReST – HTTP
Client Send Request           Server Send Response




GET / HTTP/1.1
Host: xkcd.com            HTTP/1.1 200 OK
Accept: text/html         Date: Sat, 02 Apr 2011 21:05:05 GMT
User-Agent: Mozilla/5.0   Server: lighttpd/1.4.19
(Macintosh)
                          Content-Type: text/html
                          <html>...</html>
ReST - HTTP
    HTTP Verb
●   GET
●   POST
●   PUT
●   DELETE


    Routes
●   URL + HTTP Verb
ReST - Definition


“The Same Thing with a different STATE
changes its meaning”


“The message is changed based on it's
State”
ReST – How To
●   Loved by developer
●   Easy to read, easy to
    understand, easy to learn
ReST
Bad !!                      Imagine :)


/getAllUsers                /getMentions
/getUserById                /getUserTimeLine
/getUsers                   /getHomeTimeLine
/deleteUser                 /getStatusesRetweet
/updateUser                 /updateStatuses
/deleteUserTenYearsOld      /destroyStatus
/newUser                    /getRetweets
/getUserUnderTenYearsOld
ReST - Quotes


“Web it's not about HTML pages, it's about resources,
    and those resources are located by URLs”
So ?
● We only need two base URLs as the location of a resource
(collection of resource, and single resource)
● Resources is Noun, use Noun :)

● Plural is better




    Resource    POST          GET (READ)       PUT            DELETE
                (CREATE)                       (UPDATE)


    /users      Create new    List all Users   Update All     Delete All
                user                           Users          Users


    /users/1    -             Show User        Update User Delete User
                              (with ID = 1)    with ID = 1 (if with ID = 1
                                               Exist)
Association ?
Easy :)


GET /departments/1/users
POST /departments/1/users
PUT /users/123
DELETE /users/123
Query
Use '?' for Query


GET /users?limit=50&offset=100
GET /users?username=indra&birth=1990
GET /users?column=id,name,username,birth
GET /users.json (/users.xml)
Versioning
/v1/users/
Terima Kasih




                Glend Maatita
                  @glend_maatita
                  YM : the_entung
      glend.maatita@kampus.co.id

More Related Content

PDF
20180424 #18 we_are_javascripters
PPTX
บท7
PPSX
Mannaclean| Protecting Assets, Improving Quality of Life
PPTX
Curry college old catalog
PPT
DOC
Hammett bullying-in-the-church-5.29.12-edition
PDF
Dancing with Life (BCN, Spain) March 2012
20180424 #18 we_are_javascripters
บท7
Mannaclean| Protecting Assets, Improving Quality of Life
Curry college old catalog
Hammett bullying-in-the-church-5.29.12-edition
Dancing with Life (BCN, Spain) March 2012

Viewers also liked (20)

PDF
How To Make Your Day Last Longer: Time Management in Marketing Projects
DOC
Pharmacognosy 5th sem
PDF
Understanding the state of your web application using Apache Kafka, Spark
PPTX
NEW WORLD COMING
PPT
Paycreditreport
PDF
iprocurment Buyer Guide
PPTX
Generation 3
PDF
Kidnapped nt
DOCX
Navegadores web
PDF
Philippine Java Industry
PPT
Immigration
DOC
Pharmacognosy 5th sem
PPTX
Exploring membership 3
ODP
Rails 3
PPT
2010 NYC Presentation
PDF
N efemed gs1 standaard kosten of kansen
PDF
Node.js Presentation
PDF
How to survive and thrive in the era of free shipping
PPT
СЕТЕВЫЕ ПРОЕКТЫ КАК СРЕДСТВА ФОРМИРОВАНИЯ ИНФОРМАЦИОННОЙ КОМПЕТЕНТНОСТИ ОБУЧА...
How To Make Your Day Last Longer: Time Management in Marketing Projects
Pharmacognosy 5th sem
Understanding the state of your web application using Apache Kafka, Spark
NEW WORLD COMING
Paycreditreport
iprocurment Buyer Guide
Generation 3
Kidnapped nt
Navegadores web
Philippine Java Industry
Immigration
Pharmacognosy 5th sem
Exploring membership 3
Rails 3
2010 NYC Presentation
N efemed gs1 standaard kosten of kansen
Node.js Presentation
How to survive and thrive in the era of free shipping
СЕТЕВЫЕ ПРОЕКТЫ КАК СРЕДСТВА ФОРМИРОВАНИЯ ИНФОРМАЦИОННОЙ КОМПЕТЕНТНОСТИ ОБУЧА...
Ad

Similar to PHP Indonesia 3rd meetup - 06/04/13 (20)

ODP
REST API Laravel
PDF
Rest And Rails
PPTX
L18 REST API Design
PPT
RESTful SOA - 中科院暑期讲座
PPTX
Day02 a pi.
PPTX
REST & RESTful Web Service
PPTX
Restful webservices
PPTX
Spring Boot and REST API
PPTX
Tutorial_Rest_API_For_Beginners_125.pptx
PPTX
RESTful Web Services
PPTX
rest-api-basics.pptx
PDF
REST APIS web development for backend familiarity
PPT
ROA.ppt
PDF
Getting started with DSpace 7 REST API
PDF
Data persistence using pouchdb and couchdb
PDF
Resource-Oriented Web Services
PDF
04 request-headers
PDF
RESTful web service with JBoss Fuse
PPTX
RESTful for opentravel.org by HP
PDF
Learn REST in 18 Slides
REST API Laravel
Rest And Rails
L18 REST API Design
RESTful SOA - 中科院暑期讲座
Day02 a pi.
REST & RESTful Web Service
Restful webservices
Spring Boot and REST API
Tutorial_Rest_API_For_Beginners_125.pptx
RESTful Web Services
rest-api-basics.pptx
REST APIS web development for backend familiarity
ROA.ppt
Getting started with DSpace 7 REST API
Data persistence using pouchdb and couchdb
Resource-Oriented Web Services
04 request-headers
RESTful web service with JBoss Fuse
RESTful for opentravel.org by HP
Learn REST in 18 Slides
Ad

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Cloud computing and distributed systems.
PDF
KodekX | Application Modernization Development
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
cuic standard and advanced reporting.pdf
Understanding_Digital_Forensics_Presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Cloud computing and distributed systems.
KodekX | Application Modernization Development
The AUB Centre for AI in Media Proposal.docx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Chapter 3 Spatial Domain Image Processing.pdf

PHP Indonesia 3rd meetup - 06/04/13

  • 1. ReST (Introduction) 3rd Meetup PHP Indonesia 6 April 2013 Surabaya by Glend Maatita
  • 4. ReST - History ● Representational State Transfer ● ReST was re-DISCOVER-ed by Roy Fielding ● Doesnt require any external library ● Tightly bond with HTTP
  • 5. ReST – HTTP Client Send Request Server Send Response GET / HTTP/1.1 Host: xkcd.com HTTP/1.1 200 OK Accept: text/html Date: Sat, 02 Apr 2011 21:05:05 GMT User-Agent: Mozilla/5.0 Server: lighttpd/1.4.19 (Macintosh) Content-Type: text/html <html>...</html>
  • 6. ReST - HTTP HTTP Verb ● GET ● POST ● PUT ● DELETE Routes ● URL + HTTP Verb
  • 7. ReST - Definition “The Same Thing with a different STATE changes its meaning” “The message is changed based on it's State”
  • 8. ReST – How To ● Loved by developer ● Easy to read, easy to understand, easy to learn
  • 9. ReST Bad !! Imagine :) /getAllUsers /getMentions /getUserById /getUserTimeLine /getUsers /getHomeTimeLine /deleteUser /getStatusesRetweet /updateUser /updateStatuses /deleteUserTenYearsOld /destroyStatus /newUser /getRetweets /getUserUnderTenYearsOld
  • 10. ReST - Quotes “Web it's not about HTML pages, it's about resources, and those resources are located by URLs”
  • 11. So ? ● We only need two base URLs as the location of a resource (collection of resource, and single resource) ● Resources is Noun, use Noun :) ● Plural is better Resource POST GET (READ) PUT DELETE (CREATE) (UPDATE) /users Create new List all Users Update All Delete All user Users Users /users/1 - Show User Update User Delete User (with ID = 1) with ID = 1 (if with ID = 1 Exist)
  • 12. Association ? Easy :) GET /departments/1/users POST /departments/1/users PUT /users/123 DELETE /users/123
  • 13. Query Use '?' for Query GET /users?limit=50&offset=100 GET /users?username=indra&birth=1990 GET /users?column=id,name,username,birth GET /users.json (/users.xml)
  • 15. Terima Kasih Glend Maatita @glend_maatita YM : the_entung glend.maatita@kampus.co.id