Requirements
Setting up PHPSimpleChat is easy. You need:
- Web server or hosted web space
- PHP 4.3+ (PHP 5 Recommended)
- MYSQL 4+ (MYSQL 5 Recommended) or PostgreSQL 8+ (earlier
versions may work, but are untested)
- A few minutes to install and configure
Installation
1. Unzip the PHPSimpleChat zip file into your webserver
root. By default PHPSimpleChat comes inside of a "phpsimplechat"
folder. You can place this folder in your document root. Doing
so will make PHPSimpleChat accessible by the address http://your_domain/phpsimplechat/
or http://localhost/phpsimplechat, depending on if you're working
directly on your server
2. Next, create the database "chat_database"
on your database instance. You can name your database
anything you want, but just be sure to note the name of your
database for later use. In MYSQL and PostgreSQL, this statement
will create the database: CREATE
DATABASE chat_database;
3. Edit the included config.php file with your database
connection parameters. This is where you specify
the server name, username, database name, and password used
to access your chat database. If you used a name besides "chat_database"
make sure to set the $dbName variable to this name. If you
are using PostgreSQL, read the comments in config.php carefully
as you will make to make additional edits.
4. Run the install.php file to create the necessary
database tables. This script will attempt to create
the needed tables using the memory type engine. If your MYSQL
server does not support this format, the tables will be created
using the default engine used by your database instance. To
run this file, navigate to this page in your web browser. .
Example url: http://localhost/phpsimplechat/install.php
5. Delete the install.php file. You want to remove this file from your webserver root
for security reasons, but I recommend you keep a copy of this file somewhere in case you want to
re-install the database tables.
Adding the Chat Room to Your Site
Included along with your distribution is an example chat room
setup. This file is called index.php and is in the main PHPSimpleChat
folder. You can use file as a guide to help setup a chat room
on your site.
You can add a chat room to any PHP enabled webpage. There are
a few lines of code that must be on every page.
1. Include the PHPSimpleChat main file at the top
of your script. Make sure you include the path to
the PHPSimpleChat.php in the include_once() call.
<?php
include_once('phpsimplechat/PHPSimpleChat.php');
2. Instantiate the PHPSimpleChat object.
$mychat = new PHPSimpleChat();
3. Call the displayHeader() function on the PHPSimpleChat
object. This must be done within the head section
of your script.
<head>
<title>My Chat Room</title>
<?php $mychat->displayHeader(); ?>
</head>
3. Call the displayChat() function on the PHPSimpleChat
object. This must be done within the body section
of your script.
<body>
<?php $mychat->displayChat(); ?>
</body>
4. That's it - you're done. PHPSimpleChat
has been successfully setup! Here is an example of a whole
script with a chat room installed.
<?php
include_once('PHPSimpleChat.php');
$mychat = new PHPSimpleChat();
?>
<html>
<head>
<title>My Chat Room</title>
<?php $mychat->displayHeader(); ?>
</head>
<body>
<?php $mychat->displayChat(); ?>
</body>
</html>
Going Further
PHPSimpleChat can be setup on a community driven site with
each chat user being represented by their existing username,
not the random username generated in the above example. Also,
you can instantiate more than one instance of PHPSimpleChat,
allowing you to have different chat rooms on different sections
of your site or serving different interests. For instructions
on how to do this, see the Frequently
Asked Questions section.
|