Download the PHP package s4studio/yii2-wschat without Composer
On this page you can find all versions of the php package s4studio/yii2-wschat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-wschat
Yii2 Web Socket Private Chat
Online chat based on web sockets and ratchet php. Forked: https://github.com/svbackend/yii2-wschat (public chat, with rooms). Removed MongoDB dependency as required one.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Usage
-
The chat extension can use any database storage supported by yii.
If you would like to use mysql/mariadb server keep your current DB configuration and simply import table:
If
mongodb
extension specified the chat will be try to use it as message history storage, otherwise extension will be use specified in application config db component.The simple example how to use mongodb storage is listed below. Install MongoDB and yii2-mongodb extension to store messages history and you need just specify connection in
console
config:In created mongodb database you need to create collection named as
history
; -
To start chat server need to create console command and setup it as demon:
-
Create controller which extends
yii\console\Controller
: -
Create action to start server:
- Now, you can run chat server with
yii
console command:
-
-
To add chat on page just call:
List of available options: auth - boolean, default: false user_id - mixed, default: null port - integer, default: 8080 chatList - array (allow to set list of preloaded chats), default: [ id => 1, title => 'All' ], add_room - boolean, default: true (allow to user create new chat rooms)
You can also store added chat, just specify js callback for vent events:
Chat.vent('chat:add', function(chatModel) {
console.log(chatModel);
});
This code snipped may be added in your code, but after chat widget loading. In the callback you will get access to Chat.Models.ChatRoom
backbone model. Now, you need add your code to save chat room instead console.log()
.
If
YII_DEBUG
is enabled - all js scripts will be loaded separately.
Also by default chat will try to load two images:
/avatar_16.png
and /avatar_32.png
from assets folder.
Possible issues
If you don't see any messages in console log, check flushInterval
and exportInterval
of your log configuration component. The simple configuration may looks like this:
License
MIT
All versions of yii2-wschat with dependencies
yiisoft/yii2-bootstrap Version *
cboden/ratchet Version 0.3.*
bower-asset/jquery Version 2.*
bower-asset/underscore Version 1.8.3
bower-asset/backbone Version 1.2.*
bower-asset/js-cookie Version 2.1.*
bower-asset/pnotify Version 2.0.*
bower-asset/fontawesome Version 4.*