How to implement a chat application in codeigniter website? How to implement a chat application in codeigniter website? codeigniter codeigniter

How to implement a chat application in codeigniter website?


A quick search on github gives me this:

You can think of it like a thread in a forum where someone creating a thread and the other someone make replies.

Depending on how you want to customize your apps, the interaction between the OP and those who will make replies will be rapid.

EDIT 1:

Assuming that you understand how MVC works, you can have something like this:

Your DB Structure:Table UserTable SessionTable Message

A user can be in many Session (chat room), A message can only be posted to one chat session and a user can send many messages.

In your chat page you will have a to display the conversation, a giant text box where your user can write their message and a submit button.

When a user click the submit button, it will then make an HTTP POST to your controller, where your controller will cleanse the data (i.e. $this->form_validation->set_rules();

If the posted data is valid, send it to your model where it then be stored to your database.

Everytime the chat page is loaded what you want to do is:

  1. Get the chat message for the associated session ID.

Again this is an oversimplified example. You can fork the code from the github i mentioned and try to install it on your local machine.


If you want messaging or chat and specially for codeigniter than use this library, Mahana-Messaging-library-for-CodeIgniter. I have used this, and i preferred you if you are learner. It have it's on database which you can manage and it will integrate in your project easily.


Implemented using Zopim chat widget,which is suitable for both CMS and MVC websites. https://www.zopim.com/