PHP : Best way to push data from server to clients.....?
Asked Answered
C

3

10

In my project I need to push some data from server to the client like facebook does, when some updates are performed in the clients profile like somebody writes something in the wall of the client, Facebook automatically push it to the client side.

Currently I am using AJAX to continuously check the DB for the updates. That is not a good practice.

I don't want to depended on the client side for the updates. I want that the server should automatically push the data to the client side when some updates are performed related to the client.

Please suggest some url or sample code to do so......

Thanks in advance.....

Cletis answered 22/4, 2011 at 8:32 Comment(1)
You're looking for push techniques. There are a number of implementations, check what's good for you.Shriner
D
12

You should take a look at the APE Project, which supports multiple variations that are as close to Push as you will get, like long-polling, XHRStreaming and WebSockets.

edit Doing this in just PHP is not the best choice, as it takes up a lot of resources to keep all those connections alive.

Domett answered 22/4, 2011 at 8:52 Comment(0)
S
1

you can use node.js: http://nodejs.org/

Spheroidal answered 22/4, 2011 at 8:47 Comment(2)
You have a link to a push example at hand?Mincemeat
@Mincemeat here you areThurmond
R
0

what you need is a comet/websocket approach, i do not know any PHP comet implementations/frameworks, yet there are several examples on the web when you search for it.

Rounds answered 22/4, 2011 at 8:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.