Decoupled Architecture and WordPress

31

Transcript of Decoupled Architecture and WordPress

Page 1: Decoupled Architecture and WordPress
Page 2: Decoupled Architecture and WordPress

CONTENT AS A SERVICE: DECOUPLED WORDPRESS

WITH THE REST API

Page 3: Decoupled Architecture and WordPress

Pantheon.io

Speakers

Josh Koenig

Co-Founder & Head of Product

@outlandishjosh

Page 4: Decoupled Architecture and WordPress

Pantheon.io

“Learn JavaScript Deeply”

“JavaScript is the future of the web. I

know this as surely as I know that barbecue is

delicious.”

Page 5: Decoupled Architecture and WordPress

Pantheon.io

Many Frameworks Exist

ReactJS Backbone Angular

Page 6: Decoupled Architecture and WordPress

Pantheon.io

Decoupling Client and Server

Page 7: Decoupled Architecture and WordPress

Pantheon.io

Monoliths vs. Microservices

Monolith

Templates & Themes

Display Logic

Editorial UI

Admin UI

VS.

Decoupled

Page 8: Decoupled Architecture and WordPress

Pantheon.io

The Limits of the Theme Layer as Architecture

Theme Layer

Plugins / Core

PermeableBoundary

Exciting / awkwardgame of chance

Page 9: Decoupled Architecture and WordPress

Pantheon.io

Monoliths Can Lead to Unhappy Developers

Page 10: Decoupled Architecture and WordPress

Pantheon.io

Strong Separation of Concerns

Client

WordPress

HTTP API

Everyone Wins

Page 11: Decoupled Architecture and WordPress

Pantheon.io

Use the Tools You Prefer

Page 12: Decoupled Architecture and WordPress

Pantheon.io

Parallel Track Progress

Page 13: Decoupled Architecture and WordPress

Pantheon.io

Future Proofing

Page 14: Decoupled Architecture and WordPress

Pantheon.io

Caveats

Page 15: Decoupled Architecture and WordPress

Pantheon.io

WordPress Does a Lot of Things

Page 16: Decoupled Architecture and WordPress

Pantheon.io

HTTP: Do you speak it?

Hur De Flur Shiffen de PUT Dur Skurf Nerf CURL we Flu Pur

OPTIONS me Skupplen de Noff

Page 17: Decoupled Architecture and WordPress

Pantheon.io

No, but seriously… HTTP… what r u doin?

source: https://github.com/inhabitedtype/ocaml-webmachine

Page 18: Decoupled Architecture and WordPress

Pantheon.io

Primary Use-Case: Custom Sites/Apps

Source: 2014 State of the Word

Page 19: Decoupled Architecture and WordPress

Pantheon.io

WP-API Can Grow the WP Market

Page 20: Decoupled Architecture and WordPress

MANY WAYS OF DECOUPLINGWhich is right for you?

Page 21: Decoupled Architecture and WordPress

Pantheon.io

Static Generator / Renderer

CMS

StaticSite

User Request

Static• Create a fast and resilient

user-facing site.

• Utilize front-end atomic design tools, minimal/elegant markup, etc.

• Read-only, but highly secure and scalabe.

Page 22: Decoupled Architecture and WordPress

Pantheon.io

Hybrid

CMS

StaticSite

User Request

Static• Build up a REST API on

your site to power dynamic forms/dashboards.

• Many other functions served directly from Drupal as per normal.

• Restrains the scope. Allows for particular experiences to be enhanced. CMS

JS App

User Request

Hybrid

Page 23: Decoupled Architecture and WordPress

Pantheon.io

“Single Page” App

CMS

StaticSite

User Request

Static• Client side JavaScript

application runs in-browser, pulls data from CMS via API.

• May include user interactions, or be purely content oriented.

• Typically utilize a front-end framework like Angular, Backbone, or React.

CMS

SinglePage App

User Request

Single Page

Page 24: Decoupled Architecture and WordPress

Pantheon.io

Native Mobile App / IoT

CMS

StaticSite

User Request

Static• CMS powers embedded

applications via API.

• May also present some web functionality to users.

• Drive IOS and Android native apps, as well as “internet of things” implementations.

CMS

Native Mobile

App

User Request

Native

(optional)

Page 25: Decoupled Architecture and WordPress

Pantheon.io

CMS-on-CMS

CMS

StaticSite

User Request

Static• Separation of concerns,

but not technologies.

• Front-end CMS can control configuration, caching, throttling.

• Develop reusable components for a Service-Oriented / Microservices architecture.

CMS

User Request

CMS2

CMS

Page 26: Decoupled Architecture and WordPress

Pantheon.io

Everything Old is New Again

Page 27: Decoupled Architecture and WordPress

Pantheon.io

WordPress 4.4

First REST API framework elements in core. Plugins still required for functionality.

Now is a good time for plugin developers to start thinking about API compatibility and features.

Page 28: Decoupled Architecture and WordPress

Pantheon.io

“Calypso”

ReactJS based application for administering WordPress.com sites.

Open source, a great inspirational example.

Uses Jetpack’s APIs.

Page 29: Decoupled Architecture and WordPress

LIVE DEMOHopefully the deities of demonstration are pleased…

Page 30: Decoupled Architecture and WordPress

Pantheon.io

Resources

https://github.com/Automattic/wp-calypso

https://github.com/joshkoenig/todo-wp

https://github.com/dirtystylus/wordcampus-2015-js-example

http://javascriptforwp.com/

Page 31: Decoupled Architecture and WordPress

Pantheon.io

Thanks!

Thanks! Questions?

@getpantheon