News Feed
Sections




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

Pivory.com:
From Ajax to WebSocket with PHP, a Quick Example
August 31, 2012 @ 10:41:28

On Pivory.com there's a new topic (tutorial) showing you a simple example of using WebSockets with the Ratchet PHP library, complete with sample code.

WebSocket is the modern way for realtime two-way communications between server and browser. In the beginning we have Ajax calls [...] and with WS in picture the logic becomes [different]. [There] is a separate WS server, say listening on xxx.xxx.xxx.xxx:8080, and it can send messages to connected clients in realtime at any moment. The WS server can be in any language (such as node.js + socket.io) and on any machine or even in a cloud service. I use PHP (try http://socketo.me for Ratchet) because I am lazy.

The example shows a basic PHP Web Socket server running on a port with methods for "on connect", "on close", "on error" and "on message send". There's an example of the Javascript code to connect to this socket, showing how to convert it over from Ajax usage.

0 comments voice your opinion now!
websockets tutorial ratchet library server


blog comments powered by Disqus

Similar Posts

DevShed: Parsing Web Document Nodes with the Tidy Library in PHP 5

DashExamples.com: Add a Content Security Policy(CSP) to your Web Site with PHP

SitePoint PHP Blog: Create a Movie Recommendation App with Prediction.io Implementation

Developer.com: Creating Complex, Secure Web Forms with PHP and HTML_QuickForm2

DevShed: Building an Image Generator Class with PHP 5


Community Events

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


series language laravel php7 version library extension laravel5 framework unittest voicesoftheelephpant api introduction opinion wordpress community example release interview podcast

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