Jump to content

Viability of realtime chat room coded in PHP only?


Chappers

Recommended Posts

Hi everyone,

 

Just wondering if coding a realtime chat room solely in PHP is viable? I know most use Java, but I can't learn that and the free ones have too many limitations.

 

By realtime I mean that what you type in the box appears instantly on the screen along with other users input.

 

I'm not asking for anybody to do it for me, etc., just as to whether it's possible but incredibly hard, or just impossible altogether.

 

Thanks.

Link to comment
Share on other sites

Basically, php alone is executed once per page refresh. That means that you can't run a php script without refreshing the page. Here comes as an aid javascript in it's known form ajax. This can be done with an ajax periodic updater, which checks periodically if there is any message. It should run a php script in the backend (asynchronously) that queries the database (sql or flat file) and prints the messages. As i'm no javascript expert, I usually like to have things easy in that subject, so that's why I usually use the Prototype (together with script.aculo.us for effects) javascript framework. It has some really neat and easy methods for easy ajax development. Give it a try, i'm sure you'll get the hand really fast.

Link to comment
Share on other sites

Thanks for the info, I had a feeling it wouldn't be possible with PHP alone. Sorry for being dim, but I really do know nothing about javascript and the like...what is the framework for? Is it for offline testing, etc?

 

I think there's a big learning curve ahead of me.

Link to comment
Share on other sites

If you look into socket connections you can actually do this without a heavy database back end.

 

You make a system to add a "room"  The rooms are stored in a mysql database

Users log in (also in mysql) and they can join any open room

The user then makes a socket connection to the room's IP and back and data travels between them very easily.

 

 

 

Link to comment
Share on other sites

As stated on the prototype website:

 

Prototype is a JavaScript Framework that aims to ease development of dynamic web applications.

 

It isn't just for offline testing, it's for writing javascript code with the easy of a very good framework.

Link to comment
Share on other sites

I looked at it, didn't talk in vain. Actually a shoutbox is a shoutbox. The only thing it has in common with a chat room is the possibility of posting a message :). Real time posting, users and stuff are all missing there  ;).

 

Cheers.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.