For our presentation on PHP and RIA (PowerPoint Slides) Stas and I improved the chat application originally written by Padraic Brady and featured in the Ajax Chat Tutorial. We added a number of capabilities to show some of the more advanced concepts in the Zend Framework. You can download the application by clicking this link, Improved Ajax Chat.
The modifications are as follows:
- The data handling is separated into distinct model class –
- The chat application now has log capability, meaning it preserves everything that was said and the log can be viewed later.
- The log page supports searching.
- The log supports webservice integrations with following services:
- Yahoo content analyzer – allows to find “interesting” words in the text
- Flickr image search – allows to display images that relate to specific keywords
- Amazon book search – allows to get list of books that relate to the keywords
In order to see this additional functions, do the following:
- Start chat as usual, chat for a bit (try to use long meaningful sentences so that chances of finding “interesting” keywords would be bigger)
- Click on the “chat log” link
- On the log page, click on the “Analyze” button. The keywords will be highlighted.
- Choose “Flickr” or “Amazon” radio button
- Click on a keyword and see window with service results
- Close window and repeat with different service and keywords.
The application features three action controllers – IndexController for the main chat, LogController for the log window and ServiceController implementing the conntection to services.
The data model, it uses SimpleXML to operate the chat data file, and Zend_Search_Lucene to index and search the log.
In this application, following components were used:
- Ajax Chat application by Padraic Brady
The application also uses Zend_Json::fromXML function, which is part of the xml2json proposal and was recently added to the core. It’s planned to be part of ZF 1.1 release, before that you will need Zend_Json from the incubator or SVN.
You will need Apache server to run the application. Unpack it into chat/ subdirectory in your document root, and allow .htaccess to work there (AllowOverride All). You will also need Zend Framework library to be in include_path.
chat/data subdirectory should be writable by the Apache user.