It's no denying that rich Javascript applications (sometimes called One Page Applications) are a big thing, but what if you want to leverage Drupal on the backend, or have an existing site? Tools like Angular.JS and EmberJS are great when you have an API, but Drupal 7 doesn't really have an API layer. I'll explore the parts of a one page application and how to integrate it into either an existing or a new Drupal site, and the pitfalls that one must watch out for.
Sample code for the demos are available at https://github.com/dragonmantank/spa-drupal
2. 2
Who Am I?
● A PHP Developer for 10 Years
● Drupal Dev for 4 years
● Lots of projects no one uses, and a few some
do
● https://github.com/dragonmantank
3. 3
What is a Single Page Application?
● An application that loads in a single page
4. 4
What is a Single Page Application?
1)Loads all the necessary HTML, JS, and CSS
needed in a single page load
2)Loads all the necessary HTML, JS, and CSS
needed to bootstrap an application in a single
page load
5. 5
Traditional Application Flow
Browser Server
User requests a page
Server returns page
1)Server gets request
2)Server calls PHP
3)PHP builds the HTML
User requests a page
Server returns page
1)Server gets request
2)Server calls PHP
3)PHP builds the HTML
8. 8
Single Page Application Flow
Browser Server
User requests a page
Server returns page
1)Server gets request
2)Server returns base HTML
Browser requests data
Server returns page
1)Server gets request
2)Server calls PHP
3)PHP builds the JSON
Browser requests data
Server returns page
1)Server gets request
2)Server calls PHP
3)PHP builds the JSON
Browser requests data
Server returns page
1)Server gets request
2)Server calls PHP
3)PHP builds the JSON
9. 9
SPAs Are Great!
● Reduce server load
● More responsive
● Separates server and front-end
● Make the front end people do all the work
12. 12
It's not all great
● Users have to have JS enabled
● SEO SUUUUUUUUUUCKS
● This will probably break navigation
● This will probably break your analytics
● Your host may not support it
17. 17
Create an SPA If...
● You want a more desktop-app-like
experience
● A lot of data coming and going
● You want/have a good API backend
● The interface lends itself to being a SPA
18. 18
Gmail Makes Sense
http://mashable.com/2014/03/31/email-wrong/
37. 37
What does it do?
„A standardized solution of integrating external
applications with Drupal. Service callbacks may
be used with multiple interfaces like REST,
XMLRPC, JSON, JSON-RPC, SOAP, AMF, etc.
This allows a Drupal site to provide web
services via multiple interfaces while using the
same callback code.“