ignited / laravel-sns-broadcaster
使用扩展的 Laravel SQS 驱动程序将 SNS 消息作为队列。
v1.1.1
2024-06-02 05:18 UTC
Requires
- php: >=7.4 <8.4
- ext-json: *
- aws/aws-sdk-php: ^3.305
- illuminate/broadcasting: ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/config: ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/contracts: ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
This package is auto-updated.
Last update: 2024-09-02 05:54:10 UTC
README
(从 maxgaurav/laravel-sns-broadcaster 分叉而来,但似乎已被废弃)
该包允许您将 Laravel 事件广播为 SNS 主题。
队列还处理通过 Laravel 推送的标准作业。
此包非常适合部署到微服务的应用程序。
要求
- PHP >= 7.4
- Laravel >= 8
- AWS 中的 SNS
安装
使用 composer 安装
composer require ignited/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 许可证。