使用php在XMPP上创建聊天应用程序

I am trying to create a web chat application with PHP, MySQL. I want to stream the data from the server to client instead of requesting the server in a regular intervals which will cause huge load at servers. I believe this is possible in many ways and XMPP is one of those i heard earlier, but i have no idea how to adopt this xmpp into scripts, how to use it? If some one can give some examples or code references that would be great help.

Please check the documentation of XMPP, All the social media sites including Google facebook uses XMPP in their instant messaging.

For working with XMPP on client side, you can either use websockets or http bind(aka bosh) based on your requirements and support from the xmpp server. I have tried and experimented with trophyjs and Candy.Js. Candy being slightly better in terms of plugins and support if you like chat rooms.