PHP and COMET. Need to be guided

I was looking for creating live websites using PHP. (COMET) I was looking for a very long time. (about a month) I even checked some PHP chat scripts and used them on my web server, but I had some problems for most of them. (to be explained)

So far, most people have said the same thing: PHP is not the best language that can be used with COMET. Chat / comet examples are hacked at best.

I ask about this because I want to have some features on my websites, for example, to allow users to chat with each other. This is where I need a live connection to PHP pages. I also plan to make a browser-based game, and a live connection will still be required!

AJAX was a rare thing 2 years ago, featured on Facebook. Now almost everyone uses it, and this has become the standard for web development. Now COMET-based websites are growing. Youtube, Google+, Facebook, EA Battlelog, etc. I believe that I should learn to use it.

Ok, here are my questions. (Some of the information below is the one I collected while searching on Google. Not sure if they are correct or not.)

  • Some languages, such as Python, have dedicated web servers designed for this to work. I believe one of them is called Tornado Web Server. Designed and tuned to simulate thousands of live connections. I believe Appserv doesn’t have that option, but some people said that NGINX can handle it with a decent configuration. It's true? What configurations should be made? Are there any PHP web servers for this to work?

  • Some of the most popular things are:

    and. Using APE.

    b. Using Socket.IO

    with. Node.js

    Can I use them with PHP? Which one is the most promising? Could you give them some guidance? Is there anything else?

  • script. , flush() , usleep() . ( , )

    while(true)
    {
        // query database
       // output the result
       // flush the browser
       // sleep for few seconds to lower cpu load 
    }
    

usleep() - Windows. usleep() , Windows? , "" PHP-? , , % 100 WIN UNIX.

  • PHP "" ? PHP ? , ? ( . , HTML5 AS3, AS3 , JS .)

  • WebSync? PHP?

, , COMET :

  • script, .
  • . JSON/AJAX , , . ( , , .)

, . , , . setInterval() COMET, .

+3
2

- . , , . PHP, - (, Apache) HTTP. , HTTP HTTP/1.1. , -, , Tornado Node, .

+1

Comet - , - , . , AJAX. (, ) AJAX , .

-. - PHP, pusher, . https://pusher.com/tutorials/realtime_chat_widget

- -. http://socketo.me/docs/hello-world

, .

0

All Articles