PHPackages                             coinvestor/laravel-batchsqs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. coinvestor/laravel-batchsqs

ActiveLibrary[Queues &amp; Workers](/categories/queues)

coinvestor/laravel-batchsqs
===========================

An alternative Amazon SQS queue driver for Laravel. Messages are sent in batches rather than one at a time, which may be more efficient if you have a lot of messages to send.

v0.1.10(4y ago)04.6k1[1 issues](https://github.com/CoInvestor/Laravel-BatchSQS/issues)[4 PRs](https://github.com/CoInvestor/Laravel-BatchSQS/pulls)MITPHP

Since Aug 14Pushed 4y ago5 watchersCompare

[ Source](https://github.com/CoInvestor/Laravel-BatchSQS)[ Packagist](https://packagist.org/packages/coinvestor/laravel-batchsqs)[ RSS](/packages/coinvestor-laravel-batchsqs/feed)WikiDiscussions develop Synced 3w ago

READMEChangelog (9)Dependencies (7)Versions (16)Used By (0)

Laravel-BatchSQS
================

[](#laravel-batchsqs)

SQS queue connector for Laravel which sends messages in batches.

Installation
------------

[](#installation)

To install:

`composer require coinvestor/laravel-batchsqs`

Then to publish config files:

`artisan vendor:publish`

(select the BatchSQSProvider option when prompted)

Usage
-----

[](#usage)

This package provides a queue connector called `batch-sqs`. Create a block inside `connections` as usual:

```
'connections' => [
        'batch-sqs' => [
            'driver'      => 'batch-sqs',
            'key'         => env('AWS_KEY', null),
            'secret'      => env('AWS_SECRET', null),
            'prefix'      => env('AWS_PREFIX', null),
            'queue'       => env('AWS_QUEUE', null),
            'region'      => env('AWS_REGION', null),
            'batch_size'  => 7,
        ],
// [...]
```

You can use all of the usual Laravel SQS queue config options. In addition, you can set `batch_size` to define how many messages will be included in each batch (once the batch is full, the messages will be released to the queue).

When the queue object is destroyed (e.g. at the end of the request lifecycle, when Laravel is shutting down), messages which are still waiting to be sent to the queue will be sent, even if the batch size limit has not been reached.

### Modifying messages before release

[](#modifying-messages-before-release)

When a batch of messages is released to the queue, `CoInvestor\BatchSQS\Queues\Events\BatchMessageReleasingEvent` is dispatched. To modify each message before it reaches the queue, simply define a listener which will inspect the message and then return an array which will be merged with the message before it is released:

```
