xutl/yii2-broadcast
Composer 安装命令:
composer require xutl/yii2-broadcast
包简介
The broadcast queue extension for the Yii framework
关键字:
README 文档
README
Installation
Next steps will guide you through the process of installing yii2-broadcast using composer. Installation is a quick and easy three-step process.
Install component via composer
Either run
composer require --prefer-dist xutl/yii2-broadcast
or add
"yuncms/yii2-broadcast": "~1.0.0"
to the require section of your composer.json.
Configuring your application
Add following lines to your main configuration file:
'components' => [ 'broadcast' => [ 'class' => 'xutl\broadcast\Broadcast', 'endPoint' => 'http://abcdefg.mns.cn-hangzhou.aliyuncs.com/', 'accessId' => '1234567890', 'accessKey' => '1234567890', ], //etc ],
Use broadcast
/** @var \xutl\broadcast\Broadcast $broadcast */ $broadcast = Yii::$app->broadcast; $topicName = 'CreateTopicAndPublishMessageExample'; $broadcast->create($topicName); $topic = $broadcast->getTopicRef($topicName); $subscriptionName = "SubscriptionExample"; try{ $res = $topic->subscribe($subscriptionName,'https://www.baidu.com','test.test'); echo "SubscriptionCreated! \n"; }catch (MnsException $e){ echo "CreateSubscriptionFailed: " . $e; return; } $messageBody = "test"; $res = $topic->publishMessage($messageBody, 'test.test'); var_dump($res);
class ApiController extends \yii\web\Controller { public function actions() { return [ /** * Returns an access token. */ 'callback' => [ 'class' => \xutl\broadcast\TopicAction::classname(), 'callback'=>[$this, 'callback'], ], ]; } /** * */ public function callback($params) { print_r($params); } }
License
This is released under the MIT License. See the bundled LICENSE.md for details.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-21