{"id":36989063,"url":"https://github.com/ratheeps/laravel-pub-sub-messaging","last_synced_at":"2026-01-13T23:28:25.026Z","repository":{"id":62533468,"uuid":"433349824","full_name":"ratheeps/laravel-pub-sub-messaging","owner":"ratheeps","description":"Laravel Pub/Sub Messages with Amazon SQS \u0026 SNS Extended Client Library ","archived":false,"fork":false,"pushed_at":"2021-12-07T03:06:20.000Z","size":174,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-05T19:52:20.218Z","etag":null,"topics":["event-driven","laravel","microservice","pubsub-messages","sns","sqs","sqs-queue"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ratheeps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-30T08:23:44.000Z","updated_at":"2021-12-07T02:51:03.000Z","dependencies_parsed_at":"2022-11-02T16:01:15.345Z","dependency_job_id":null,"html_url":"https://github.com/ratheeps/laravel-pub-sub-messaging","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ratheeps/laravel-pub-sub-messaging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratheeps%2Flaravel-pub-sub-messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratheeps%2Flaravel-pub-sub-messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratheeps%2Flaravel-pub-sub-messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratheeps%2Flaravel-pub-sub-messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ratheeps","download_url":"https://codeload.github.com/ratheeps/laravel-pub-sub-messaging/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratheeps%2Flaravel-pub-sub-messaging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-driven","laravel","microservice","pubsub-messages","sns","sqs","sqs-queue"],"created_at":"2026-01-13T23:28:22.391Z","updated_at":"2026-01-13T23:28:25.021Z","avatar_url":"https://github.com/ratheeps.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Pub/Sub Messaging with AWS\n\nSimple extension to the [Illuminate/Queue](https://github.com/illuminate/queue) queue system used in [Laravel](https://laravel.com) and [Lumen](https://lumen.laravel.com/).\n\nUsing this connector allows [SQS](https://aws.amazon.com/sqs/) messages originating from a [SNS](https://aws.amazon.com/sns/) subscription to be worked on with Illuminate\\Queue\\Jobs\\SqsJob.\n\nThis is especially useful in a miroservice architecture where multiple services subscribe to a common topic with their queues and  publish an event to SNS.\n\n## Amazon SQS \u0026 SNS Extended Client Library\n\nThe **Amazon SQS Extended Client Library for Laravel** enables you to manage Amazon SQS message payloads with Amazon S3. This is especially useful for storing and retrieving messages with a message payload size greater than the current SQS limit of 256 KB, up to a maximum of 2 GB. Specifically, you can use this library to:\n\n* Specify whether message payloads are always stored in Amazon S3 or only when a message's size exceeds a max size (defaults to 256 KB).\n* Send a message that references a single message object stored in an Amazon S3 bucket.\n* Get the corresponding message object from an Amazon S3 bucket.\n\n```diff\n- Note: This package under development not ready for production -\n```\n\n## Requirements\n\n-   Laravel (tested with version \u003e=7.0)\n\n## Installation\n\n\n1. First create a disk that will hold all of your large SQS payloads.\n\n\u003e We highly recommend you use a _private_ bucket when storing SQS payloads.  Payloads can contain sensitive information and should never be shared publicly.\n\n2. Run `composer require ratheeps/laravel-pub-sub-messaging` to install the package.\n\n3. Then, add the following queue settings to your `queue.php` file.\n\n```php\n\u003c?php\nreturn [\n    'connections' =\u003e [\n        'pub-sub-messaging-sqs' =\u003e [\n            'driver' =\u003e 'pub-sub-messaging-sqs',\n            'key' =\u003e env('PUB_SUB_MESSAGING_AWS_ACCESS_ID'),\n            'secret' =\u003e env('PUB_SUB_MESSAGING_AWS_SECRET_ACCESS_KEY'),\n            'prefix' =\u003e env('PUB_SUB_MESSAGING_SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),\n            'queue' =\u003e env('PUB_SUB_MESSAGING_SQS_QUEUE', 'default'),\n            'suffix' =\u003e env('PUB_SUB_MESSAGING_SQS_SUFFIX'),\n            'region' =\u003e env('PUB_SUB_MESSAGING_AWS_DEFAULT_REGION', 'us-east-1'),\n            'after_commit' =\u003e false,\n            'disk_options' =\u003e [\n                'always_store' =\u003e true,\n                'cleanup' =\u003e false,\n                'disk' =\u003e env('PUB_SUB_MESSAGING_DISK', 'pub_sub_messaging_s3'),\n                'prefix' =\u003e '',\n            ],\n        ],\n    ],\n];\n```\n\n4 Then, add the following disk settings to your `filesystems.php` file.\n\n```php\n\u003c?php\nreturn [\n    'disks' =\u003e [\n        'pub_sub_messaging_s3' =\u003e [\n            'driver' =\u003e 's3',\n            'key' =\u003e env('PUB_SUB_MESSAGING_AWS_ACCESS_ID'),\n            'secret' =\u003e env('PUB_SUB_MESSAGING_AWS_SECRET_ACCESS_KEY'),\n            'region' =\u003e env('PUB_SUB_MESSAGING_AWS_DEFAULT_REGION'),\n            'bucket' =\u003e env('PUB_SUB_MESSAGING_AWS_BUCKET'),\n            'url' =\u003e env('PUB_SUB_MESSAGING_AWS_URL'),\n            'endpoint' =\u003e env('PUB_SUB_MESSAGING_AWS_ENDPOINT'),\n            'use_path_style_endpoint' =\u003e env('AWS_USE_PATH_STYLE_ENDPOINT', false),\n        ],\n    ],\n];\n```\n\n5. You can optionally publish the config file with \n`php artisan vendor:publish --provider=\"Ratheeps\\PubSubMessaging\\PubSubMessagingServiceProvider\" --tag=\"config\"` this command\nThen, modify the following pub sub settings to your `pub-sub-messaging.php` file.\n\n```php\n\u003c?php\nreturn [\n    'default_topic' =\u003e env('PUB_SUB_MESSAGING_DEFAULT_TOPIC'),\n    'default_auth_driver' =\u003e null,\n    // map the jobs to subscribe SNS topics to handle the consuming events\n    'map' =\u003e [\n//        \\App\\Jobs\\TestSQSJob::class =\u003e 'arn:aws:sns:ap-southeast-1:931616835216:modelEvent',\n    ],\n    'published_attributes' =\u003e [\n        'id',\n        'created_at',\n        'updated_at'\n    ],\n    'sns' =\u003e [\n        'key' =\u003e env('PUB_SUB_MESSAGING_AWS_ACCESS_KEY'),\n        'secret' =\u003e env('PUB_SUB_MESSAGING_AWS_SECRET_ACCESS_KEY'),\n        'region' =\u003e env('PUB_SUB_MESSAGING_AWS_DEFAULT_REGION', 'us-east-1'),\n        'disk_options' =\u003e [\n            // Indicates when to send messages to S3., Allowed values are: ALWAYS, NEVER, IF_NEEDED.\n            'store_payload' =\u003e 'IF_NEEDED',\n            'disk' =\u003e env('PUB_SUB_MESSAGING_DISK', 'pub_sub_messaging_s3'),\n            'prefix' =\u003e ''\n        ]\n    ]\n];\n\n```\n\n6. You'll need to configure .env file\n```dotenv\nPUB_SUB_MESSAGING_AWS_ACCESS_ID=\nPUB_SUB_MESSAGING_AWS_SECRET_ACCESS_KEY=\nPUB_SUB_MESSAGING_AWS_DEFAULT_REGION=ap-south-1\n\nPUB_SUB_MESSAGING_DEFAULT_TOPIC=\nPUB_SUB_MESSAGING_AWS_BUCKET=\nPUB_SUB_MESSAGING_DISK=pub_sub_messaging_s3\n\nQUEUE_CONNECTION=pub-sub-messaging-sqs\nPUB_SUB_MESSAGING_SQS_QUEUE=\n\n```\n\n8. Boot up your queues and profit without having to worry about SQS's 256KB limit :)\n\n### Consuming Event\nCreate a job like below to handle the event and then map that job to SNS topic in the `pub-sub-messaging.php` config file\n```php\n\u003c?php\nuse Illuminate\\Bus\\Queueable;\nuse Illuminate\\Queue\\SerializesModels;\nuse Illuminate\\Queue\\InteractsWithQueue;\nuse Illuminate\\Contracts\\Queue\\ShouldQueue;\nuse Illuminate\\Foundation\\Bus\\Dispatchable;\nuse Illuminate\\Support\\Facades\\Log;\n\nclass TestSQSJob implements ShouldQueue\n{\n    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;\n\n    protected $passedInData;\n\n    /**\n     * Create a new job instance.\n     *\n     * @param array $data\n     */\n    public function __construct(array $data)\n    {\n        // $data is array containing the msg content from SQS\n        $this-\u003epassedInData = $data;\n    }\n\n    /**\n     * Execute the job.\n     *\n     * @return void\n     */\n    public function handle()\n    {\n        Log::info(json_encode($this-\u003epassedInData));\n        // Check laravel.log, it should now contain msg string.\n    }\n}\n\n```\n\n### Published event\n\n```php\n\u003c?php\nnamespace App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Ratheeps\\PubSubMessaging\\Traits\\SNSPublisher;\n\nclass Post extends Model\n{\n    use SNSPublisher;\n\n    /**\n     * @var array\n     * Optional (default value is [] )\n     * Witch are the attributes should only from SNS message\n     */\n    static $publishedAttributes = [\n        'id',\n        'created_at',\n        'updated_at'\n    ];\n\n    /**\n     * @var array\n     * Optional  (default value is [created','updated','deleted','restored'] )\n     * Witch events should send to SNS\n     */\n    static $publishEvents = ['created', 'updated'];\n\n    /**\n     * @var string\n     * Optional (default value is load from config )\n     * Publish SNS topic\n     */\n    static $publishTopic = 'SampleTopic';\n    /**\n     * Or\n     * static $publishTopic = [\n     *  'created' =\u003e 'SampleTopic'\n     * ];\n     */\n}\n```\n## Diagram\nThis diagram will be describing how your microservices are communicating with help of this package\n![Diagrams](https://raw.githubusercontent.com/ratheeps/laravel-pub-sub-messaging/master/diagrams.png)\n\n## References\n* **Sign up for AWS** -- Before you begin, you need an AWS account. For more information about creating an AWS account and retrieving your AWS credentials, see [AWS Account and Credentials](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html?highlight=credentials) in the AWS SDK for PHP Developer Guide.\n* **Sign up for Amazon SQS** -- Go to the Amazon [SQS console](https://console.aws.amazon.com/sqs/home?region=us-east-1) to sign up for the service.\n* **Minimum requirements** -- To use the sample application, you'll need PHP 7.0+ and [Composer](https://getcomposer.org/). For more information about the requirements, see the [Getting Started](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/) section of the Amazon SQS Developer Guide.\n* **Further information** - Read the [API documentation](http://aws.amazon.com/documentation/sqs/) and the [SQS \u0026 S3 recommendations](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/s3-messages.html).\n* **SNS Large payload** - Read the [AWS Java SDK documentation](https://docs.aws.amazon.com/sns/latest/dg/large-message-payloads.html)\n* **SQS Large payload** - Read the [AWS Java SDK documentation](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-s3-messages.html)\n* **Pub/Sub Messaging** - Read the [Documentation](https://aws.amazon.com/pub-sub-messaging/)\n\n## Feedback\n* Give us feedback [here](https://github.com/ratheeps/laravel-pub-sub-messaging/issues).\n* If you'd like to contribute a new feature or bug fix, we'd love to see Github pull requests from you.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratheeps%2Flaravel-pub-sub-messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fratheeps%2Flaravel-pub-sub-messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratheeps%2Flaravel-pub-sub-messaging/lists"}