REST in Pieces: Working with the WordPress REST API in an Object-oriented Fashion

Slides – external Link

Since both the infrastructure and the first set of endpoints of the WordPress REST API got merged into Core, it’s obvious for plugin and even theme authors to jump on the bandwagon. If you are interested in a sweeping statement about this, this one’s for you.

In the first part of this talk, Thorsten briefly looks back on the history of introducing a REST API to WordPress. He then comments on the current state of WordPress Core, and what we might expect in the (near) future.

The currently suggested way to develop using the WordPress REST API includes using a handful of functions and maybe writing up a custom class that extends a gigantic abstract controller class provided by WordPress Core. In essence, this results in procedural code, with the used functions not even being pure (as they are using global variables).

That’s why the second part of this talk is about WP REST Starter, a Composer package for working with the WordPress REST API in an object-oriented fashion. Using the interfaces and default implementations provided by WP REST Starter helps you write proper object-oriented code that is easier to understand, easier to extend, easier to test, and easier to maintain. Furthermore, in case the internals of the WordPress REST API will ever change, you can rely on WP REST Starter taking care of this, if possible.

No need to adapt any of your RESTful WordPress projects.

Speaker

Published by

Thorsten Frommen

Thorsten is a certified PHP engineer, web development professional and tester. He is working in the web since 2000, and with (and on) WordPress since 2005. Thorsten is a Principal Engineer at Syde. A big fan of open source, Thorsten created several plugins and other projects, but also contributed to existing open source projects. Also, he is an advocate of object-oriented design, and software testing. Since the first official German WordCamp in Hamburg in June 2014, Thorsten fell in love with both the WordPress community and WordCamps, in particular, where he likes to both gain and share knowledge.

WordCamp Vienna 2017 is over. Check out the next edition!