If you're searching for a small simplistic chat but don't want some Flash, Java or other heavy-weight stuff you can stop searching. A PHP capable webserver and three files are all you need. And no, you don't need a database.
This code here is inteded as a base for you to do your own stuff. However if it already is exactly what you want feel free to just copy it.
example.phpfile from the download.
messages.jsonfile and make sure the webserver can read and write it.
That's it. :)
Everyone can post messages in the chat below. Give it a try if you want to see the chat in action.
Take a look at the source code of
example.php (it also
shows the PHP code). It's a stripped down version of the chat so there are no fancy styles or documentation (except
some comments) to distract you.
This simple design leads to a chat that doesn't need a database nor a large server or infrastructure. Just a small bunch of lines you can drop into your project and modify or extend as needed. It's so simple that it shouldn't be a problem to extend or adopt the code for your own purpose (e.g. multiple chat rooms, usage as message API, fancy styling, etc.).
If you want to know more take a look at the detailed explanation of the design and implementation of this chat.
This archive contains everything you need for this chat: simple-chat-v1.0.1.zip.
It's the stripped down chat example (
example.php) as well as
jquery-1.4.2.min.js) and a shell script to create an empty file that's writeable by everyone
setup.sh, just in case…).
If you have questions about this chat or want to share some thoughts or ideas, please post a comment on the blog post of this project. You can also send me a mail if you prefere that.
actionattribute of the form).
Copyright (c) 2010 Stephan Soller <firstname.lastname@example.org>.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.