jonsutherland/laravel-sns-sqs-sub-pub
Composer 安装命令:
composer require jonsutherland/laravel-sns-sqs-sub-pub
包简介
A simple Laravel service provider which adds a new queue connector to handle SNS subscription queues.
关键字:
README 文档
README
simple extension to the Illuminate/Queue queue system used in Laravel and Lumen.
Using this connector allows SQS messages originating from a SNS subscription to be worked on with Illuminate\Queue\Jobs\SqsJob.
This is especially useful in a miroservice architecture where multiple services subscribe to a common topic with their queues and publish an event to SNS.
Requirements
- Laravel (tested with version 5.8)
- or Lumen (tested with version 5.8)
Installation
You can install the package via composer
composer require jeylabs/laravel-sns-sqs-sub-pub
You can optionally publish the config file with:
php artisan vendor:publish --provider="Mvjacobs\SnsSqsPubSub\SnsSqsPubSubServiceProvider" --tag="config"
This is the contents of the published config file:
<?php return [ 'default_topic' => 'SampleTopic', 'default_auth_driver' => null, 'map' => [ \App\Jobs\TestSQSJob::class => 'SampleTopic', ], 'published_attributes' => [ 'id', 'created_at', 'updated_at' ], 'sns' => [ 'key' => env('SNS_SQS_PUB_SUB_AWS_ACCESS_KEY'), 'secret' => env('SNS_SQS_PUB_SUB_AWS_SECRET_ACCESS_KEY'), 'region' => env('SNS_SQS_PUB_SUB_AWS_DEFAULT_REGION', 'us-east-1'), ] ];
Configuration
You'll need to configure the queue connection in your config/queue.php
<?php return [ 'connections' => [ 'sns-sqs-sub-pub' => [ 'driver' => 'sns-sqs-sub-pub', 'key' => env('SNS_SQS_PUB_SUB_AWS_ACCESS_KEY'), 'secret' => env('SNS_SQS_PUB_SUB_AWS_SECRET_ACCESS_KEY'), 'prefix' => env('SNS_SQS_PUB_SUB_SQS_PREFIX', 'https://sqs.ap-southeast-1.amazonaws.com/your-account-id'), 'queue' => env('SNS_SQS_PUB_SUB_QUEUE_URL', 'your-queue-name'), 'region' => env('SNS_SQS_PUB_SUB_AWS_DEFAULT_REGION', 'us-east-1'), ], ], ];
Once the sns-sqs-sub-pub queue connector is configured you can start using it by setting queue driver to 'sns-sqs-sub-pub' in your .env file.
Job class example
<?php use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Support\Facades\Log; class TestSQSJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; protected $passedInData; /** * Create a new job instance. * * @param array $data */ public function __construct(array $data) { // $data is array containing the msg content from SQS $this->passedInData = $data; } /** * Execute the job. * * @return void */ public function handle() { Log::info(json_encode($this->passedInData)); // Check laravel.log, it should now contain msg string. } }
Published event
<?php namespace App; use Illuminate\Database\Eloquent\Model; use Mvjacobs\SnsSqsPubSub\Traits\SNSPublisher; class Post extends Model { use SNSPublisher; /** * @var array * Optional (default value is [] ) * Witch are the attributes should only from SNS message */ static $publishedAttributes = [ 'id', 'created_at', 'updated_at' ]; /** * @var array * Optional (default value is [created','updated','deleted','restored'] ) * Witch events should send to SNS */ static $publishEvents = ['created', 'updated']; /** * @var string * Optional (default value is load from config ) * Publish SNS topic */ static $publishTopic = 'SampleTopic'; /** * Or * static $publishTopic = [ * 'created' => 'SampleTopic' * ]; */ }
You'll need to configure .env file
SNS_SQS_PUB_SUB_AWS_SNS_DEFAULT_TOPIC=sampletopic SNS_SQS_PUB_SUB_AWS_ACCESS_KEY= SNS_SQS_PUB_SUB_AWS_SECRET_ACCESS_KEY= SNS_SQS_PUB_SUB_AWS_DEFAULT_REGION=ap-southeast-1 SNS_SQS_PUB_SUB_SQS_PREFIX=https://sqs.ap-southeast-1.amazonaws.com/your-account-id SNS_SQS_PUB_SUB_QUEUE_URL=https://sqs.ap-southeast-1.amazonaws.com/your-account-id/your-queue-name
jonsutherland/laravel-sns-sqs-sub-pub 适用场景与选型建议
jonsutherland/laravel-sns-sqs-sub-pub 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.49k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「queue」 「aws」 「laravel」 「sqs」 「event-driven」 「SNS」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jonsutherland/laravel-sns-sqs-sub-pub 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jonsutherland/laravel-sns-sqs-sub-pub 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jonsutherland/laravel-sns-sqs-sub-pub 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP AMQP Binding Library
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
A Laravel package to monitor queue jobs.
Elastic Driver for Laravel Scout
simple api library.
A replica of the AWS Elastic Beanstalk worker SQS daemon (sqsd) in PHP
统计信息
- 总下载量: 15.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04