Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Websockets in Your Synchronous Site
Feb 26, 2016 @ 17:03:53

The SitePoint PHP blog has a new tutorial from Christopher Pitt showing you how to integrate websockets into your application for asynchronous, real-time functionality. His method makes use of a service called Socketize (with a free tier available).

Asynchronous architecture is common in other programming languages, but it’s only just finding its feet in PHP. The trouble is that this new architecture comes with a cost.

I don’t talk about that cost enough. [...] When I recommend frameworks like Icicle, ReactPHP, and AMPHP, the obvious place to start with them is to create something new. [...] It takes a lot of work to integrate new, asynchronous features into existing applications. Often there are good reasons and great benefits, but a rewrite is always a hard-sell. [...] I’m going to show you a Sockets-as-a-Service service, called Socketize.

He walks you through the setup of the code and account to create a simple CRUD (create, read, update, delete) system for a deck of cards. He starts with a simple synchronous API spitting back JSON of the card data. Then he creates the frontend client (simple Javascript) to fetch the data and append the values to the page. Next comes the asynchronous handling - he shows the creation of the Socketize account, setting up a new application (with keys) and making use of the SocketizeJavascript client to create the websocket and hook it all together.

tagged: websockets asynchronous socketize application frontend service thirdparty

Link: http://www.sitepoint.com/websockets-in-your-synchronous-site/


Trending Topics: