Chat system in Zend Framework website - php

In my website, I have to make a chat system similar to Gmail so registered users can chat with their group. I have no idea about how I will do this. Can anyone provide me with an idea of how to implement this or any useful links? I have to do it using Zend Framework.

Since you are looking to work this out using Zend framework, have a look at Jaxl library (Jabber XMPP Client/Component Library). The library can be integrated with any existing website/framework and also contains several examples for browser based chat applications.

Actually there are two parts for chatting:
A long running request that streams massges from the server to the client
Ajax messages from the client to the server that sends one message to the server
For the second, any ajax framework will do it. For the first you might have a look at Comet to get the idea for this. But you should be aware that html isn't ment to be a chatting protocol. If you don't pay attention such stuff can easily kill your server.

Related

implementing a chat webapplication

I need to develop a web application with a chat feature, and I would like to know if there are any sophisticated ways to create a realtime web-application with a push engine.
I know jQuery, and I can handle to create a chat web-application which, in the client side, check every period for new messages, and show them, but I don't like this solution and I was wondering if there are any better ways to do it.
In my research I discovered the existence Ajax Push Engine project, and it looks like what I need, but when I was navigating in their website I found it not very well done and somehow incomplete, so I was wondring if there API is stable enough to be put in a production environment if not are there any other solutions?
Sorry if I made it long, any help/hint/link/suggestion would be very welcomed :)
EDIT
I would like to specify that I'm working with PHP in the server side
Here is an implementation in NodeJs.
http://dhotson.tumblr.com/post/271733389/a-simple-chat-server-in-node-js
I recently (year 2012) developed an application in ASP.NET MVC3 where I used SignalR for real-time messaging between server and client. At their own site, they describe SignalR like this:
ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
... and they give the following example of what you can use SignalR for:
SignalR can be used to add any sort of "real-time" web functionality to your ASP.NET application. While chat is often used as an example, you can do a whole lot more. Any time a user refreshes a web page to see new data, or the page implements Ajax long polling to retrieve new data, is candidate for using SignalR.
Further, based on my experience, I believe it is very simple to set up, easy to use, and have a good github page with well-written documentation that gets you going in no time. I can highly recommend it :)

Does drupal or joomla allow a combination node.js and socket.io with php?

I'm looking into the development of a site where socket use is a must for real time updates. I understand with wordpress it is difficult to incorporate node.js and socket.io and was wondering if this is the case with drupal. Specifically could I incorporate node.js and socket.io with php? What specific steps would I need to take? I appreciate the help and of course if you give me a good answer, I'll rate you up.
There are currently Node.js modules that connect to Drupal, Joomla, and WordPress. I wrote the one for Joomla: https://github.com/jlleblanc/nodejs-joomla You can find all of these through NPM. First, you would download one of these modules, then you would also download the Socket.io module. Then you would write server side code connecting the CMS to Socket.io. Finally, you would write client-side code to talk to the socket running in Node.
You can have it separated and since you want some client-server communication with node.js, you can have it - outside Drupal (this is the easiest and cleanest way).
CMS you use (be it Drupal or Wordpress) does not limit your JavaScript from using socket.io and node.js for the calls you want to be made outside the CMS server-side code. You can eg. read the same database Drupal/Wordpress does, but using Node.js and returning the results directly to the client-side JavaScript script.
You can integrate Socket.IO with whatever technology you like, but you need to think of them as 2 separate parts that need to communicate.
I see 2 solutions for Socket.IO to communicate with an external service (Drupal, Joomla, Wordpress, whatever):
1) Making a rest API for your Socket.IO application (for example using Express for the API layer and then passing messages to Socket.IO with an EventEmitter).
2) The better solution in my opinion is to use a message queue like Redis, RabbitMQ or ZeroMQ. The Drupal website would send a message down the channel to Socket.IO and then Socket.IO would send that message to the client(s).
If you are creating a system that needs authentication also, I suggest you don't let your users send message directly with Socket.IO, but make an Ajax call to your main server instead (Drupal for ex.). That way you can check the user's identity more easily. (This scenario would be a fit for a chat based system that requires authentication)
Although this video tutorial is for EventMachine with Faye, the same logic could apply to your app: http://railscasts.com/episodes/260-messaging-with-faye

C2DM Application Server solution

Can anyone recommend a tutorial or point me in the direction of some easily implemented .net or PHP code that i could use to setup a third party application server for C2DM.
I am a Front-End Developer with some PHP/.net experience, but very minimal Java experience, our app is setup with the required java code/classes and I have registered with C2DM, but i'm struggling with the application server part of the equation.
I would like to setup a server application that can handle form requests to send a message out to our app.
Any help or advice would be greatly appreciated!
The server part of C2DM is a piece of cake compare to the client (in my opinion). You can find below some tutorials about the server part :
One for JAVA very easy to understand even if your are not JAVA developper.
One for PHP and Zend framework.
A basic example for C# on stackoverflow
A common mistake to avoid if you want some performance : Don't connect for each message to send.
You just have to auth one time to the google server and then you can send multiple notification message.
Also don't forget that Google will periodically refresh the token in an Update-Client-Auth header. You should handle this header to keep your tokens up to date. Have look to this discussion about it
You may want to have a look at this post. It is a basic PHP implementation using curl.
I am building a server-side C2DM based on Drupal CMS.
While it is not 100% ready, if you want I can try and help you building it.
Using Drupal as the server-side, and its amazing modules such as Services and Rules, you can create a very interesting applications very easy, almost "out-of-the-box".

What are my options for creating an iPhone app from an existing PHP website?

I have an existing PHP/MySQL website that relies hugely on form POSTs for things like signing up, logging in, searching etc. I now need to create a native iPhone app for it. The business requires a native app for marketing reasons, I can't get away with a mobile optimized website.
I'm looking for suggestions from someone who has already done this - how did you rewire your website to POST/GET data from the iPhone app? I'm guessing I'll have to send/receive data as XML, which is then parsed by the server and client. Is there anything simpler or any framework that can make this easier?
Thanks!
If you don't have some sort of webservices or API to connect through for the website I would make that my first priority. While you can scrape HTML and send POST requests, it can get quite messy FAST. I've created iPhone apps which talk with webservices through SOAP requests, and have built an iPhone interface to a site, which wasn't pretty. It is very doable, but it is also very frustrating if anything changes on the webpage.
If you are looking for a decent library to help you get started with POSTing against forms check out the ASIHTTPRequest library at http://allseeing-i.com/ASIHTTPRequest/. If you look at the site there is a 'How to Use It' page with 'Sending Data with POST or PUT Requests'. Otherwise you could just use NSURLRequest and NSURLConnection and handle everything yourself.
It depends a lot on what you are presenting. You may be able to put a lot of your php heavy interfaces into web pages. The web pages and all related resources would be local to, and formatted for the iPhone. You can look at PhoneGap for examples of how to host local web pages and communicate with the host application.
I have been writing an eBook reader. About half of the user interface is done through local html files. In my case there is no network access, but WebKit is the easiest way to style text.
As long as your application does not look like a web page, it is fine if it is a web page. That may simplify big chunks of server interaction, especially things like login that only happen once or rarely.
Jonathan,
I would recommend taking a look at the Apple provided SeismicXML sample app. It uses the NSXMLParser to parse XML in a asynchronous fashion which will be huge for your app. It also shows how to use a NSURLConnection to make the request off of the web. You can use the NSURLConnection (which is also asynchronous) for POST/GET requests.
As mentioned in another answer, the ASIHTTPRequest library from allseeing-i.com is an excellent library but all of the features you want can be done using the built in Apple APIs if needed for your business requirements.
Hope this helps!

PHP Jabber Integration

I am wondering how to integrate jabber instead of using my AJAX polling script. I chanced upon the following: http://code.google.com/p/xmpphp/
It gives me access to a jabber server, but does not tell me how to exactly go about it. I mean for example
$payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
Are there a fixed set of commands that I can use? Is there some site which explains the jabber workflow in very simple terms?
Thank you very much for your time.
I've been wondering about technologies to play around with XMPP, been looking at:
Strophe
BOSH
Examples of this technology can be seen at:
drop.io
Chesspark
These two doc pages seem to be fairly readable:
Core
Instant Messaging and Presence
Also, you might already be heavily invested into xmpphp, but if not, you may want to take a look at Phurple. It gives you access to the libpurple library (the code-base for Pidgin) from PHP.
From the project page:
This libpurple PHP binding, which
defines a set of internal classes,
gives a possibility to use aol and icq
(oscar), yahoo, msn, jabber, irc and
much more protocols directly from PHP.
Write your own IM chat client in PHP,
as simply as PHP enables it.

Categories