PHPackages                             freelancerua/yii2-chat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. freelancerua/yii2-chat

ActiveYii2-extension[Framework](/categories/framework)

freelancerua/yii2-chat
======================

Yii2 real-time chat

12021PHP

Since Oct 4Pushed 7y ago2 watchersCompare

[ Source](https://github.com/freelancerua/yii2-chat)[ Packagist](https://packagist.org/packages/freelancerua/yii2-chat)[ RSS](/packages/freelancerua-yii2-chat/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Installation
============

[](#installation)

Add to composer.json

```
"freelancerua/yii2-chat": "@dev"

```

Configuration
=============

[](#configuration)

1. Apply migrations. To apply migration set config in console application as following:

    ```
    'controllerMap' => [
        // Migrations for the yii2-chat extension
        'migrate-chat' => [
            'class' => \freelancerua\yii2\chat\migrations\MigrationController::class,
            'migrationNamespaces' => ['freelancerua\yii2\chat\migrations'],
            'migrationPath' => null,
            'migrationTable' => 'migration_chat',
            'userTable' => '{{%user}}', // Change it if user table has different name
        ],
    ],

    ```

    Now you can run:

    ```
    ./yii migrate-chat/up

    ```
2. Setup Redis. For Ubuntu you can follow this instruction:
3. Configure yii2-chat extension:

    ```
    modules' => [
        'chat' => [
            'class' => \freelancerua\yii2\chat\Module::class,
            'socketAddress' => 'http://[domain|IP]:[port]',  // Required
            'userClass' => path\to\user::class, // Required
            'onlineWidow' => (60 * 3), // Required (3 minutes or other time)
            ...
        ],
    ],

    ```

    You can use other module name e.g. yiichat Best way add this configuration to main-local.php (for advanced app)
4. Follow this instructions to update/setup Node.js to version 10.x:

    ```
    https://github.com/nodesource/distributions#debinstall

    ```
5. Install pm2 manager:

    ```
    npm install pm2 -g

    ```
6. In terminal go to

    ```
    [@vendor]/freelancerua/yii2-chat/node/

    ```
7. Update modules:

    ```
    npm update

    ```
8. Copy config.example.json to config.json and setup confg values:

    ```
    {
        "serverPort": 8890,
        "serverIP": "[IP]", // Exact as your domain or IP set in socketAddress (https required for ssl)
        "redisPort": 6379,
        "redisName": "127.0.0.1",
        "redisAuth": null
        "ssl": false,
        "key": "path_to_key",
        "cert": "path_to_pem"
    }

    ```
9. Start and add a process to the pm2 process list:

    ```
    pm2 start [@vendor]/freelancerua/yii2-chat/node/server.js --name yii2-chat-server

    ```
10. Implement IChatInterface to user class

    - getChatImage() &amp; getChatName() depends your class realization
    - getIsOnline() &amp; setIsOnline() must be exact as below:

    ```
    getIsOnline()
    {
        return (\freelancerua\yii2\chat\Module::getInstance()->onlineWidow
                    + $this->chat_is_online) > time();
    }
    setIsOnline()
    {
        $this->chat_is_online = time();
        return $this->update(false);
    }

    ```

    If you plan to use this function in not module context do not forget bootstrap this module.

    ```
    'bootstrap' => [..., 'chat']

    ```

Module config options you can change
====================================

[](#module-config-options-you-can-change)

```
```
/**
 * {@inheritdoc}
 */
public $db = 'db';

/**
 * Default chat assets folder
 * @var string
 */
public $assets = '@vendor/freelancerua/yii2-chat/assets';

/**
 * Default chat style file
 * @var string
 */
public $styleFile = 'css/chat.css';

/**
 * Default chat js file
 * @var string
 */
public $jsFile = 'js/chat.js';

/**
 * Format message date when send and update state
 * @var string
 */
public $jsDateFormat = 'DD/MM/YYYY H:mm:ss';

/**
 * Format message date with PHP
 * @var string
 */
public $phpDateFormat = 'php:d/m/Y H:m:s';

/**
 * Redis instance name
 * @var type
 */
public $redis = 'redis';

/**
 * Redis DB host
 * @var string
 */
public $redisHost = '127.0.0.1';

/**
 * Redis DB port
 * @var integer
 */
public $redisPort = 6379;

```

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35457589?v=4)[Dmytro S.](/maintainers/freelancerua)[@freelancerua](https://github.com/freelancerua)

---

Top Contributors

[![freelancerua](https://avatars.githubusercontent.com/u/35457589?v=4)](https://github.com/freelancerua "freelancerua (20 commits)")

### Embed Badge

![Health badge](/badges/freelancerua-yii2-chat/health.svg)

```
[![Health](https://phpackages.com/badges/freelancerua-yii2-chat/health.svg)](https://phpackages.com/packages/freelancerua-yii2-chat)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
