Yii

  1. Integrating with Yii 2
  2. Integrating with Yii 1.1.x

Yii 2

Introduction

This guide will help you through the installation process and get CometChat running on your site.

Installation is very straight forward, only taking about 5 minutes from uploading the files to viewing the CometChat bar on your site.

Before you begin, you will need an FTP client, if you do not have one, some popular solutions include FileZilla (free) or CuteFTP (trial).

This guide assumes that you have successfully downloaded the latest release of CometChat and have the zip file “unzipped” and ready to go. If not, you can download the package from the Members Area.

The instructions will term the zip file you downloaded as cometchat.zip.

Uploading

At this point, you should have the zip archive cometchat.zip and find a single folder- “cometchat”.

If you don’t know already, find out the folder in which Yii is installed.

If you access your Yii site via ‘http://www.domain.com’, then look for the webroot directory.

The “webroot” directory is usually ‘public’, but this varies from server to server so if you’re unsure, contact your hosting provider.

Using your FTP client, copy the ‘/cometchat’ folder inside your Yii folder. e.g. http://www.domain.com/cometchat

Configuration

Add your database information

Edit integration.php and update the DATABASE details.

/* DATABASE */

$db_usertable = '';
$db_usertable_name = '';
$db_usertable_userid = '';
$db_avatartable = '';
$db_avatarfield = '';

These 5 lines specify details about your database schema.

$db_usertable specifies the name of the table in which your user information is stored. For eg: The table name is ‘tbl_users’.
$db_usertable_name specifies the name of the field from users table in which the user’s name/display name is stored. For eg: The name of the field in user’s table is ‘username’.
$db_usertable_userid specifies the name of the field from users table in which the user’s id is stored (usually id or userid or user_id or member_id). This field must be of integer type. For eg: The name of the field in which user’s id is stored is ‘id’.
$db_avatartable specifies join of users table with avatar table. If avatar is stored in the users table then leave this field blank.
$db_avatartable is the user ID by default. You can change this if your site stores avatar in users or avatars table. For eg: ‘tbl_users.avatar’.

The code will look like:

$db_usertable = 'tbl_users';
$db_usertable_name = 'username';
$db_usertable_userid = 'id';
$db_avatartable = '';
$db_avatarfield = 'tbl_users.avatar';

Installation

* Step 1

You should now run the installer file through your web browser by entering the URL into your browser’s address bar (if you have followed our example, type in http://www.domain.com/cometchat/install.php, naturally substituting ‘domain.com’ for your web address).

If the installation was completed successfully, then two code snippets will be displayed on your screen. The first code is for docked themes like Glass, Hangout, Facebook etc. and the second is for embedded theme i.e. Synergy. Please copy the appropriate lines of code depending on whether you wish to use docked themes or embedded theme. Also the page may display a list of files and folders which may require additional permissions. Please CHMOD those files/folders to 777.

* Step 2

To use docked theme in Yii’s Basic Template:

Edit your template header file which is ‘<Yii_Root_Folder>/views/layouts/main.php’. Add the copied code immediately after the opening head tag:

<head>
<link type="text/css" href="<Yii_Root_Folder>/cometchat/cometchatcss.php" rel="stylesheet" charset="utf-8">
<script type="text/javascript" src="<Yii_Root_Folder>/cometchat/cometchatjs.php" charset="utf-8"></script>

To use docked theme in Yii’s Advanced Template:

Edit your template header file which is ‘<Yii_Root_Folder>/frontend/views/layouts/main.php’ and ‘<Yii_Root_Folder>/backend/views/layouts/main.php’. Add the copied code immediately after the opening head tag:

<head>
<link type="text/css" href="<Yii_Root_Folder>/cometchat/cometchatcss.php" rel="stylesheet" charset="utf-8">
<script type="text/javascript" src="<Yii_Root_Folder>/cometchat/cometchatjs.php" charset="utf-8"></script>

To embed CometChat in your site:

Add the code copied for embedded theme from step 1 in your site’s HTML code to embed the chat.

Now delete install.php file from the ‘/cometchat’ folder.

That’s all! Now log-in to your site and you will be able to see the CometChat bar. For customizing the text, icons, plugins, theme and modules, please refer to the documentation for Administration Panel.

Yii 1.1.x

Introduction

This guide will help you through the installation process and get CometChat running on your site.

Installation is very straight forward, only taking about 5 minutes from uploading the files to viewing the CometChat bar on your site.

Before you begin, you will need an FTP client, if you do not have one, some popular solutions include FileZilla (free) or CuteFTP (trial).

This guide assumes that you have successfully downloaded the latest release of CometChat and have the zip file “unzipped” and ready to go. If not, you can download the package from the Members Area.

The instructions will term the zip file you downloaded as cometchat.zip.

Uploading

At this point, you should have the zip archive cometchat.zip and find a single folder- “cometchat”.

Note:
The Unpacked Yii release directory will be referred to as the Yii Framework Folder (eg: Yii).
The folder created during Yii installation, using command will be referred as the Yii Application Folder (eg: yiisite).

If you do not know already, find out the folder in which Yii Application folder is installed.

If you access your Yii site via ‘http://www.domain.com’, then look for the webroot directory.

The “webroot” directory is usually ‘public’, but this varies from server to server so if you are unsure, contact your hosting provider.

Using your FTP client, copy the ‘/cometchat’ folder inside your Yii Application folder (yiisite). eg: http://www.domain.com/cometchat

Configuration

Edit /cometchat/integration.php and update the DATABASE and Yii FRAMEWORK details.

/* DATABASE */

$db_usertable = '';
$db_usertable_name = '';
$db_usertable_userid = '';
$db_avatartable = '';
$db_avatarfield = '';

These 5 lines specify details about your database schema.

$db_usertable specifies the name of the table in which your user information is stored. For eg: The table name is ‘tbl_users’.
$db_usertable_name specifies the name of the field from users table in which the user’s name/display name is stored. For eg: The name of the field in user’s table is ‘username’.
$db_usertable_userid specifies the name of the field from users table in which the user’s id is stored (usually id or userid or user_id or member_id). This field must be of integer type. For eg: The name of the field in which user’s id is stored is ‘id’.
$db_avatartable specifies join of users table with avatar table. If avatar is stored in the users table then leave this field blank.
$db_avatarfield is the user ID by default. You can change this if your site stores avatar in users or avatars table. For eg: ‘tbl_users.avatar’.

The code will look like:

$db_usertable = 'tbl_users';
$db_usertable_name = 'username';
$db_usertable_userid = 'id';
$db_avatartable = '';
$db_avatarfield = 'tbl_users.avatar';

/* Name of the Yii Framework folder */

define('YII_FRAMEWORK','');

YII_FRAMEWORK specifies the name of your Yii Framework folder. For eg: The name of the folder is ‘Yii’.

In our example, the code will look like:

define('YII_FRAMEWORK','Yii');

Installation

* Step 1

You should now run the installer file through your web browser by entering the URL into your browser’s address bar (if you have followed our example, type in http://www.domain.com/cometchat/install.php, naturally substituting ‘domain.com’ for your web address).

If the installation was completed successfully, then two code snippets will be displayed on your screen. The first code is for docked themes like Glass, Hangout, Facebook etc. and the second is for embedded theme i.e. Synergy. Please copy the appropriate lines of code depending on whether you wish to use docked themes or embedded theme. Also the page may display a list of files and folders which may require additional permissions. Please CHMOD those files/folders to 777.

* Step 2

To use docked theme:

Now edit your template header file which is ‘<Yii_Application_Folder>/protected/views/layouts/main.php’. Add the copied code immediately after the opening head tag:

<head>
<link type="text/css" href="<Yii_Application_Folder>/cometchat/cometchatcss.php" rel="stylesheet" charset="utf-8">
<script type="text/javascript" src="<Yii_Application_Folder>/cometchat/cometchatjs.php" charset="utf-8"></script>

To embed CometChat in your site:

Add the code copied for embedded theme from step 1 in your site’s HTML code to embed the chat.

Now delete install.php file from the ‘/cometchat’ folder.

That’s all! Now log-in to your site and you will be able to see the CometChat bar. For customizing the text, icons, plugins, theme and modules, please refer to the documentation for Administration Panel.

  • Was this helpful?
  • Yes   No