Slides from J and Beyond 2013 presentation.
You have probably heard of REST and Web Services. In this presentation you will learn what they are and why they are important to the future of Joomla. You will learn why it is important for the API to be HAPI, what the HATEOAS constraint is and why developers should always keep it in mind when writing clients and servers on the new API, and why moving to a services-first design philosophy is important for everyone involved in Joomla software development.
2. Architectural Style of the Web
"The World Wide Web has succeeded in large
part because its software architecture has been
designed to meet the needs of an Internet-
scale distributed hypermedia system."
Fielding, Roy Thomas. Architectural Styles and the Design of Network-based Software Architectures.
Doctoral dissertation, University of California, Irvine, 2000.
6. What is REST?
2000: Fielding's PhD dissertation
● REST (Representational State Transfer)
● Architectural style for building scalable,
distributed, hypermedia applications.
● The architectural style that has been used
to guide the design and development of
the World Wide Web's architecture.
7. REST constraints
● client-server
● stateless
● cache
● uniform interface
● layered system
● code-on-demand (optional)
The important point is to not unintentionally
violate these constraints.
8. Client-server
Client and server may be
● developed at different times
● by different people
● evolving at different rates
But they must always have a
Shared Understanding
9. Resource-based
Resources are identified by URIs:
www.example.com/articles/1234
Note: This might be the same resource at some point in time:
www.example.com/articles/latest-news
10. Manipulation of resources via
representations
Ceci n'est pas une pipe
Translation: "This is not a pipe"
11. Self-descriptive messages
There must be enough information in each
message for the recipient to understand it.
Self-contained messages have their limits.
There will always be out-of-band information
needed to understand messages. The problem
is where to draw the line.
12. Hypermedia constraint
Hypermedia as the engine of application state
● Clients drive application state by
○ following hypermedia links
○ or submitting forms
● Clients should treat URL's as opaque
○ except for URI Templates (RFC 6570)
● Fielding: "Servers must have the freedom to
control their own namespace"
○ Servers can change URIs without breaking clients
15. What about Joomla?
● Mobile (and other) devices
● Internet of Things
● Open data
● Integrating business processes
● Electronic Data Interchange (EDI)
16. Joomla is an information silo
Components can't easily
communicate with each other
17. Joomla Hypermedia Services
● Break Joomla components/modules into
smaller "services".
● Services have a uniform interface
○ JInput for input
○ JSON, XML, HAL, etc. for output
● Services communicate using media types
○ application/vnd.joomla.*
○ Additional constraints using schemas/profiles
25. What's inside a service?
Services
Server (Joomla)
HAPI
C
M
V
RAD/SDK/FoF
CLI
Drupal 8
HAPI
26. Web Services Working Group
http://docs.joomla.org/Web_Services_Working_Group
● Web Services Specification
○ currently at second draft
● Sample code
○ based on new MVC in Joomla 3.x
○ structure allows it to be retrofitted to any component
without touching existing code
○ articles, weblinks, categories
○ can be browsed with any generic HAL client
28. Hierarchy of media types
JSON
HAL
vnd.joomla.service
vnd.joomla.list
vnd.joomla.item
XML
Remember: Shared understanding
29. WSWG Next Steps
http://docs.joomla.org/Web_Services_Working_Group
● Web Services Specification
○ more people to read and comment
● Coding
○ more people to write code for a J3.x implementation
○ client SDK (JavaScript and PHP versions)
● Future
○ more people to work on an architecture for Joomla
beyond the 3.x cycle
30. Questions?
Play with a demo at
http://demo.davenporttechnology.com/api/hal-browser/browser.html#http://demo.davenporttechnology.com/api
Thank you for listening
31. Image credits
http://commons.wikimedia.org/wiki/File:Paris_-_Jardin_du_Luxembourg_-_le_soir.JPG License: GNU
FDL
http://en.wikipedia.org/wiki/File:Crying-girl.jpg License: CC-A-SA 2.0
http://www.veezzle.com/photo/1529836/Class-of-2007-USAF-Academy-Graduation-Hat-Hurray-Toss-
Thunderbird-Fly-Over License: CC-A 3.0
http://en.wikiversity.org/wiki/File:Alvano-Sabina-pipe.jpg License: GNU FDL
http://commons.wikimedia.org/wiki/File:Ralls_Texas_Grain_Silos_2010.jpg License: Public domain