CakePHP Ajax Chat Demo (v1.2) Question/Comments

Loading...

Notes

- Version 1.2 fixes compatibility with CakePHP 1.2.

- Version 1.1 adds the message to the chat window immediately using javascript.

ReadMe

  1. You'll need a working version of CakePHP installed. This is running on 1.2.0.6311 beta.
  2. Download Prototype and put it in /app/webroot/js/
  3. Download and unzip the contents to app/plugins. The plugin is called "chat", so make sure there is no conflict with any other controllers/plugins
  4. Run this sql to create the chats table.
    CREATE TABLE  `chats` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `key` varchar(45) NOT NULL default '',
      `handle` varchar(20) NOT NULL default '',
      `text` text NOT NULL,
      `ip_address` varchar(12) NOT NULL default '',
      `created` datetime NOT NULL default '0000-00-00 00:00:00',
      PRIMARY KEY  (`id`),
      KEY `KEY_IDX` (`key`)
    );
  5. Include the helper in your controller
    var $helpers = array('Ajax', 'chat/AjaxChat');
  6. Include Prototype in your view if you don't already include it in your layout.
    echo $javascript->link('prototype');
  7. Then just add the chat to your view. You can have multiple chats on your site by changing the chat key - "chat1" in this example.
    echo $ajaxChat->generate('chat1');