Today we have highlights from two more NZ PHP Conference speakers. SilverStripe's Solutions Architect Ingo Schommer shares his highlights from Nate Abele's talk on Hypermedia APIs and developer Ed Linklater shares his highlights from Chris Pitt's presentation on Asynchronous PHP.
6 Highlights from Nate Abele - Designing Hypermedia APIs with PHP
Nate Abele is probably best known for his contributions to Open Source, including helping to create one of the most well-known and widely-used web frameworks for PHP. The 5 years’ experience working on a large, high-adoption project has helped to inform and guide his current crop of Open Source projects (he co-founded the Lithium PHP framework, and is a member of the AngularUI team), writing, teaching, and consulting. Back in the 'dark ages' he also wrote CakePHP.
- REST makes software resilient through well defined boundaries. Needs stable base through API versioning.
- APIs should allow for “evolvability” over time. One API-wide version number often too coarse (waterfall release cycle)
- Versioning through content negotiation can keep variations in check. Example of normalising address data in later API release: Accept: application/vnd.radify.user.json vs. application/vnd.radify.user+address.json
- Feature flags through query params, HTTP headers, sessions, users can keep API nimble
- JSON is not a meaningful hypertext format, use HAL, Collection+JSON, Siren to provide metadata. Links to self, relations, pagination.
- Linked resources should always be identified by a URL, not a database identifier. The URL can contain an identifier but that’s an implementation detail.
You can see Nate's presentation on Hypermedia APIs here.
5 Highlights from Chris Pitt - Asynchronous PHP
Chris Pitt is a developer at Joe Public in Cape Town, South Africa. Chris has been programming since leaving school a decade ago. He is the author of "Laravel 4 Cookbook", involved in numerous open source projects and regularly speaks at conferences.
- PHP is synchronous to the core, by design. There’s a basic async implementation in HHVM/Hack, but not everyone has the option of using that.
- There are many queues and job servers (e.g. php-resque, Gearman) that you can use to get background tasks done, but nothing quite like the node.js event loop. React aims to fill that gap.
- Works out of the box using StreamSelectLoop, but for more performance you can install libevent, libev or event pecl extensions.
- Is its own HTTP server, much like node.js.
- Can be paired with Ratchet for a great WebSockets implementation in PHP.