renatomaldonado/laravel-sqs-consume
| Install | |
|---|---|
composer require renatomaldonado/laravel-sqs-consume |
|
| Latest Version: | v2.0.0 |
| PHP: | ^8.1 |
| License: | MIT |
| Last Updated: | Jul 21, 2026 |
| Links: | GitHub · Packagist |
laravel-sqs-consumer
A custom SQS connector for Laravel (or Lumen) that supports many jobs e any message types based in library https://github.com/dusterio/laravel-plain-sqs.
But each job will be responsible for one queue sqs. All will be execute, if message in some queue exists it will be processed.
Dependencies
- PHP >= 8.1
- Laravel 10, 11, 12 or 13 (Lumen 10 or 11 — Lumen's final release was 11.x)
Installation via Composer
To install simply run:
composer require renatomaldonado/laravel-sqs-consume
Usage in Laravel
// Add in your config/app.php
'providers' => [
'...',
'Renatomaldonado\LaravelSqsConsume\Provider\LaravelSQSQueueServiceProvider',
];
Usage in Lumen
// Add in your bootstrap/app.php
$app->register(Renatomaldonado\LaravelSqsConsume\Provider\LumenSQSQueueServiceProvider::class);
Configuration
// Generate standard config file (Laravel only)
php artisan vendor:publish --provider="Renatomaldonado\LaravelSqsConsume\Provider\LaravelSQSQueueServiceProvider"
// In Lumen, create it manually (see example below) and register it in bootstrap/app.php
$app->configure('sqs-consumer');
Edit config/sqs-consumer.php to suit your needs. This config matches SQS queues with handler classes.
return [
/**
* Queues array for execute in each job
*/
'queues' => ['queue-sqs-name-example', 'queue-sqs-name-example-two'],
'handlers' => [
'queue-sqs-name-example' => 'your-job',
'queue-sqs-name-example-two' => 'your-job-two',
],
'default-handler' => 'job-default'
];
If queue is not found in 'handlers' array, SQS payload is passed to default handler.
Add sqs-consumer connection to your config/queue.php, eg:
...
'sqs-consumer' => [
'driver' => 'sqs-consumer',
'key' => env('AWS_KEY', ''),
'secret' => env('AWS_SECRET', ''),
'prefix' => 'https://sqs.ea-northheast-1.amazonaws.com/123456/',
'queue' => 'queue-sqs-name-example',
'region' => 'ea-northheast-1',
],
...
In your .env file, choose sqs-consumer as your new default queue connection:
QUEUE_CONNECTION=sqs-consumer
Receiving from SQS
If a third-party application is creating custom-format JSON messages or any message, just add a handler in the config file and implement a handler class as follows:
use Illuminate\Contracts\Queue\Job as LaravelJob;
class ExempleJob extends Job
{
protected $data;
/**
* @param LaravelJob $job
* @param $data
*/
public function handle(LaravelJob $job, $data)
{
// This is incoming JSON payload, already decoded to an array
var_dump($data);
// Raw JSON payload from SQS, if necessary
var_dump($job->getRawBody());
}
}
Related Packages
A simple Laravel service provider which adds a new queue connector to handle SNS...
Adds a Laravel queue driver for Amazon SQS FIFO queues.
Run Laravel (or Lumen) tasks and queue listeners inside of AWS Elastic Beanstalk...
Custom SQS connector for Laravel that supports custom format JSON