maxgaurav / laravel-sns-broadcaster
使用扩展的 Laravel SQS 驱动器将 SNS 消息作为队列。
v1.1.0
2020-08-05 08:59 UTC
Requires
- php: ^7.2
- ext-json: *
- aws/aws-sdk-php: ^3.62
- illuminate/broadcasting: 6.* || 7.*
- illuminate/config: 6.* || 7.*
- illuminate/contracts: 6.* || 7.*
- illuminate/support: 6.* || 7.*
This package is auto-updated.
Last update: 2024-09-23 21:32:32 UTC
README
该软件包允许您将 Laravel 事件作为 SNS 主题进行广播。
队列还会处理通过 Laravel 推送的标准作业。
该软件包非常适合部署到微服务的应用程序。
要求
- PHP >= 7.2
- Laravel >= 6
- Laravel 的 SQS 驱动器
- AWS 中的 SNS
安装
使用 composer 安装
composer require maxgaurav/laravel-sns-broadcaster
该软件包将自动注册其服务提供者。
配置
驱动设置
更新您的 .env 文件,使用广播驱动器
BROADCAST_DRIVER=sns
环境设置
TOPIC_SUFFIX=-dev #leave it blank, if you are trying to deploy base
广播配置设置
在 config/broadcasting.php 中添加以下驱动设置
return [ 'null' => [ 'driver' => 'null', ], 'sns' => [ 'driver' => 'sns', 'region' => env('AWS_DEFAULT_REGION'), 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'suffix' => env('TOPIC_SUFFIX', '-dev'), 'arn-prefix' => env('TOPIC_ARN_PREFIX', 'arn:aws:sns:us-east-2:123345666:') // note the arn prefix contains colon ], ];
事件设置
在您的事件中实现 ShouldBroadcast 接口。然后通过 broadcastOn 方法设置要返回的主题名称。
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; class SampleEvent implements ShouldBroadcast { /** * @inheritDoc */ public function broadcastOn() { return "you-topic-name"; // the topic without the prefix and suffix. Example user-created. If -dev is suffix then it will automatically appended } }
许可证
MIT 许可证。