kriss/yii2-web-msg-sender Yii2 web msg sender with workerman

Yii2 Web Msg Sender

  1. Installation
  2. Usage

Yii2 web msg sender with workerman

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist kriss/yii2-web-msg-sender "*"

or add

"kriss/yii2-web-msg-sender": "*"

to the require section of your composer.json file.

Usage

1. Config

in web.php or main-local.php

<?php
use kriss\webMsgSender\WebMsgSender;

return [
    'components' => [
        // others
        WebMsgSender::COMPONENT_NAME => [
            'class' => WebMsgSender::class,
            'pushApiClientHost' => 'localhost',
            'logCategory' => 'webMsgSender',
        ],
    ],
];
2. Console Server

config in console/config

<?php
return [
    'controllerMap' => [
        'web-msg-sender-service' => [
            'class' => \kriss\webMsgSender\ServiceController::class,
        ],
    ],
];

then start server by

php yii web-msg-sender-service/start
3. View Client

in views/layout or other view file

<?= \kriss\webMsgSender\ClientReceiveWidget::widget(['uid' => Yii::$app->user->id]) ?>

open browser and open the view

4. Send One Msg For Test
<?php
use kriss\webMsgSender\WebMsgSender;
use yii\helpers\Html;

WebMsgSender::getComponent()->getSender()->sendInfo('You Have A Message,' . Html::a('[clickMe]', 'http://www.baidu.com'));
5. Preview

preview

0 0
1 follower
13 downloads
Yii Version: 2.0
License: MIT
Category: Web Service
Tags: alert, message
Developed by: kriss
Created on: Sep 28, 2018
Last updated: (not set)
Packagist Profile
Github Repository

Related Extensions