Introducing MemChat: Open source group chat framework in PHP supporting Memcached, APC, SQLite, Flat Files and MySQL

Introducing MemChat: Open source group chat framework in PHP supporting Memcached, APC, SQLite, Flat Files and MySQL

MemChat is an open source group chat framework for personal and enterprise level websites. Written in PHP, MemChat can be configured to run with Memcached, APC, SQLite, Flat files and MySQL as it’s storage engine. With memcached, APC and Flat files serving as temporary storages and MySQL, SQLites being permanent storage engines.

MemChat uses MemBurger API for storing all the incoming messages in the storage engine. MemBurger is an open source PHP wrapper for all the storage engines mentioned above providing Collapsed Forwarding and Stale-While-Revalidate functionality.

MemChat can also be configured to notify the site owners at various event handlers provided. e.g. In case of a wordpress blog, site owner might want to get notified when someone post a new message on one of the blog post. Infact developers can write plugins for custom event handlers. MemChat provides two kind of notification methods. By default, MemChat uses XMPP protocol to notify blog owners. For these kind of notifications, JAXL an open source Jabber XMPP Client Library is used to send instant messages as notifications. MemChat can also be configured to send notifications using SMTP protocol a.k.a EMail.

MemChat also comes with a profanity word filter using PHProfane library i.e. one can configure MemChat to block all spam messages posted in the chat rooms. Developers can write a plugin to add custom spam words in the profanity filter.

MemChat Flow Diagram:
Below is a flow diagram showing how all the above components are clubbed in as MemChat:
MemChat Workflow Diagram

MemChat use cases:
MemChat framework requires a unique alphanumeric id for each group you want to create. For example, WordPress blog makes a good environment to setup MemChat since every blog post have a unique id. Hence to setup MemChat on a wordpress blog all we need to do is, call

$memchat_ui_html = memchat_init($memchat_group_id);

method, where $memchat_group_id = Blog post id.

Similarly MemChat can be setup on a number of places as listed below:

  1. Forums: Since each forum have a unique id per discussion thread, MemChat suits well here. Forum owners can setup MemChat for allowing current viewing users of the thread to chat in real time. If using temporary storage engines (since they scale up well), forum owners can easily write event handlers to save chat messages asynchronously so that interesting discussions can be made a part of actual discussion thread.
  2. Social Networking Websites: A social network will generally have group pages, fan pages, event pages and application pages. Since all pages will have a unique id associated with them, MemChat is a good fit here. Simply pass $blog_id = “group-1234”, for setting up a chat room on group page having id 1234. Similarly for fan, event and application pages.
  3. Blogs: A blog as discussed above is a perfect place for setting up MemChat. WordPress blog owners will be able to setup MemChat on their blog using WP-Chat plugin.

Setting up MemChat in 3 steps:
MemChat can be setup in 3 simple steps:

  1. Download: MemChat is hosted on Google Code.
  2. Update Configuration: Update MemChat config file to setup various default behavior and actions.
  3. Initialize: Include MemChat class file in your PHP template.

    Next simply initialize MemChat

    $memchat_ui_html = memchat_init($memchat_group_id);

    which will return the user interface HTML code. Finally append it to your template and MemChat group is ready to serve.

The ease of setup can be imagine from the fact that, WP-Chat wordpress plugin development required only the above 3 steps. I was able to develop the plugin within 5 minutes.

MemChat Performance Benchmark
Initial benchmarking results show, On a single apache and single storage instance MemChat is capable of handling over 250 (MySQL) incoming chat messages per second. Capacity reaches in thousands when configured with Memcached or APC cache. Again Memcached configuration and APC no stat feature makes a difference in performance results.

Why still in alpha?
Yes, MemChat is still in alpha release. I want to test all MemChat features on a live traffic and hence I chose my blog for its testing. I have installed MemChat on my blog which is currently using APC cache as storage medium. Over two weeks or so I will configure MemChat with various other storage engines to have a final round of test. Also the event handler and PHProfane plugin feature is still under development. MemBurger API also requires a more modular design pattern so that extending it for any other storage types become trivial.

Try out MemChat on my blog, can be seen as a facebook type chat bar below. This will be soon available as WP-Chat plugin for wordpress blogs. WP-Chat user interface is customizable just like wordpress themes.

Let me know your views and suggestions for improvement.


  1. Pingback: Introducing MemChat: Open source group chat framework in PHP … | Open Hacking

  2. Pingback: Wordpress Plugins » Blog Archive » Introducing MemChat: Open source group chat framework in PHP …

  3. Pingback: uberVU - social comments

    1. Yes as I wrote it is still in alpha and available on my blog for a demo. I wanted to test it on live traffic to be sure nothing is getting screwed. Configuring and tuning can take upto 2-3 weeks depending upon how much the readers are using it 😀

  4. Chris

    Hey, that’s exactly what I have been looking for – and finally wanted to create on my own, because I didn’t found it.

    I’d offer you to take part in the development – if interested, please contact me.

    Some points after the first review:
    – Input field not obvious.
    – Links not highlighted.
    – What about user authentication (integration of user database/existing sessions)?
    – What about linking of user names to user profiles?
    – Are multiple Memcached servers possible (selected by group id?)


    1. Hi Chris,

      MemChat is also a pluggable chat module with handlers provided for almost every event happening in the background. Hence:

      1. Customing UI is not an issue, infact UI is a separate component all together and you can change the UI theme by a simply change in config file.

      2. You have handler on the incoming chat messages. Write a plugin and hyperlink the fields before saving. Other way, if you don’t want to alter incoming messages while saving, write a plugin on the outgoing chat message chunks. Hyperlink while displaying chat messages.

      3. Again can be handled with plugins. Currently a method is called when a new uses logs in. You can write plugin for that method to authenticate in the background.

      4. Again same as hyperlinking

      5. Yup, multiple memcached clusters are possible. Support will be there for storage engines like mongodb, couchdb and the likes.

      Overall you can visualize MemChat architecture similar to wordpress CMS. Every thing is customizable.

    1. Yes any PHP based CMS will be fine. Basically all MemChat requires as input is a unique id for your chat group to function.

      Admin panel etc all should be added as plugins. Since MemChat framework allows you a handler for all events occurring in a chat group, making an admin panel should be easy 😀

    1. Yeah I will be making available a few plugins to start with. But thereafter you can only reply on open source community.

      Since it will be open source, I assume developers might like to use available handlers for making their own custom plugins. If they wish, they can make them open source too (though not sell, due to license restrictions)

      For instance a very quick example can be, making a website stats module using memchat handler. Since memchat enabled pages sends atleast 1 query on page load, you can use it for stats collection too.

    1. Hi Andy,

      I am currently testing the xmpp/jabber version of memchat. My jabber server was giving me problem by aborting sessions with 403 forbidden error. Hence disabled it for non-admins.

      Shall see something coming up by this weekend, i m pretty tied at work 🙁

  5. Christian

    Hi Abhinav, sounds good what you are writing but even if you still develop: why do you not checkin into the google-code svn repository so others can help you or give the project more spirit?

  6. Pingback: Introducing WP-Chat :: XMPP Chat plugin for Wordpress | Abhi's Weblog

  7. Andyleery

    Hi, finally! Waiting for month 🙂
    I just registered and would like to try it out. Is it possible to get a German translation?

    I could do it by myself and I would also provide it to you. Just send me the language file (XML or whatever you guys use). All the best for your projects!

    – Andy

Comments are closed.