Download the PHP package joni-jones/yii2-wschat without Composer

On this page you can find all versions of the php package joni-jones/yii2-wschat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-wschat

Web Socket Chat

Online chat based on web sockets and ratchet php

Latest Stable Version Scrutinizer Code Quality Total Downloads License Join the chat at https://gitter.im/joni-jones/yii2-wschat

![Demo] (doc/demo.gif)

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

  1. The chat extension can use any database storage supported by yii.

    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;

    IMPORTANT: if you use db component - you need to create table history in your database. The simple examples postgresql and mysql you can see in tests/codeception directory.

  2. 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:

    If you want to use chat for auth users, you must to specify userClassName property for ChatManager instance. For example:

    • Now, you can run chat server with yii console command:
  3. To add chat on page just call:

    or if you want to use chat for auth users just add config as parameter:

    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:

If you use https protocol chat will try to connect to wss instead ws. But Ratchet PHP does not support work via SSL, so you need to use some proxy like stunnel.

License

MIT


All versions of yii2-wschat with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
yiisoft/yii2-mongodb Version 2.1.*
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.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package joni-jones/yii2-wschat contains the following files

Loading the files please wait ....