News Feed
Sections




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

SitePoint PHP Blog:
Building a Live-score Widget Using PHP Web Sockets
October 17, 2013 @ 10:11:42

On the SitePoint PHP blog there's a new post from Lukas White about using PHP and web sockets to create a "live score" widget to include in your site.

The introduction of web sockets makes it possible for web applications to handle near real-time data without resorting to "hacks" such as long-polling. One example of an application requiring up-to-the-minute data is sports scores. Even now, many websites which display this information use Flash applications, since Actionscript provides the facility to communicate over socket-based connections. However, web sockets allow us to replicate this functionality using only HTML and Javascript. That's what we're going to build in this tutorial, along with a lightweight "server" in PHP.

His example uses the Ratchet PHP library to provide the WebSockets functionality to the frontend script polling for the latest data. He helps you get the library installed and set up a simple directory structure for the example. He includes sample scripts for both the data provider (for the scores) and the WebSocket provider. He talks about maintaining the state of the data and shows how to pull out random data from a set of fixtures (pre-defined data) to send back to the frontend. The Javascript for the frontend script is also included.

0 comments voice your opinion now!
tutorial websockets live score example javascript ratchet

Link: http://www.sitepoint.com/building-live-score-widget-using-php-web-sockets/

blog comments powered by Disqus

Similar Posts

The Bakery: Basic User Authentication in (CakePHP) 1.2.x

PHP-Coding-Practices.com: How I Turned A Slow Array Sort Into A Quick One Using Quicksort Algorithm

Wan Qi Chen: Background jobs with php and resque (Series, Parts 4, 5 & 6)

SitePoint PHP Blog: Bringing Unicode to PHP with Portable UTF-8

Community News: php|architect and Pro PHP Podcast Team Up


Community Events





Don't see your event here?
Let us know!


series bugfix community deployment language interview zendserver laravel install introduction release package symfony voicesoftheelephpant framework api podcast unittest library opinion

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework