PHP code example of slavkovrn / yii2-chat

1. Go to this page and download the library: Download slavkovrn/yii2-chat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

slavkovrn / yii2-chat example snippets


return [
    'modules' => [
        'chat' => [
            'class' => 'slavkovrn\chat\ChatModule',
            'numberLastMessages' => 30,
        ],
    ],
]; 

namespace app\models;
...
use app\models\Profile;
class User extends ActiveRecord implements IdentityInterface
{
    public function getChatname()
    {
        return Profile::find()->where(['id' => Yii::$app->user->id])->one()['name'];
    }
 
    public function getChaticon()
    {
        return Profile::find()->where(['id' => Yii::$app->user->id])->one()['photo'];
    }
    ...