christoph-kluge/bref-sqs-laravel
Integrates AWS SQS with Laravel applications deployed using Bref, simplifying queued job dispatch and processing on AWS Lambda. Provides configuration and worker support for serverless SQS queues.
christoph-kluge/bref-sqs-laravel bridges AWS SQS to Laravel's queue pipeline so a Bref/Lambda function can consume queued jobs without running a long-lived queue:work daemon. You still dispatch() jobs the Laravel way; the package handles turning an SQS batch from the Lambda invocation event into Laravel job executions.
Minimal path:
bref/bref 1.3.*. Install both together:
composer require christoph-kluge/bref-sqs-laravel:^2.0 bref/bref:^1.3
If you are on bref 1.2.x, stay on the 1.x line of this package.php artisan vendor:publish and pick the package provider — the README lists the tag) and read config/bref-sqs.php first; that file and the package's job class are the two places that explain the whole integration.sqs connection in config/queue.php (driver sqs, region, prefix/queue URL) and keep your existing connection as the default so only explicitly-routed jobs go to SQS.serverless.yml using Bref's artisan handler plus the package's single-invocation consumer command, with an SQS event source:
functions:
worker:
handler: artisan
runtime: php-81
timeout: 30
layers: [ ${bref:layer.php-81} ]
command: [ '<package SQS consumer command from README>' ]
events:
- sqs:
arn: !GetAtt JobsQueue.Arn
batchSize: 1
ProcessOrder::dispatch($orderId) on the sqs connection; deploy; drop a message and confirm it appears in CloudWatch logs and lands in jobs/failed_jobs semantics you expect. Start with batchSize: 1 while you learn the retry behaviour.orders, emails, exports) and a separate function/event source per queue so each can have its own timeout, memory, and concurrency. Don't multiplex unrelated workloads on one SQS queue.handle(). SQS caps messages at 256 KB and Laravel's serialized model payload gets large fast.$timeout (and the connection's retryAfter) comfortably below the function timeout, and the function timeout below the queue's visibility timeout. This is the ordering that prevents duplicate processing.maxTries/backoff and the failed_jobs table. AWS-side: the queue's redrive policy (maxReceiveCount → DLQ) for invocations that never reach Laravel's failure handling. Align the numbers so a job doesn't bounce forever in one layer while the other looks healthy.failed() on the job covers application exceptions; a redrive DLQ covers cold-start crashes, OOM, and timeouts. Add alerting on both, and remember queue:retry/Horizon tooling does not apply to SQS.QUEUE_CONNECTION=database or sync locally and exercise jobs with dispatchSync() or queue:work --once. For end-to-end Lambda testing use serverless invoke local / SAM with a recorded SQS event fixture, or bref local against the consumer command.serverless.yml. Put APP_KEY, queue URLs, and AWS region in provider.environment or SSM; build config/route caches at deploy time, not at invocation time. Grant the function sqs:ReceiveMessage, DeleteMessage, GetQueueAttributes, and ChangeMessageVisibility.composer why-not bref/bref 1.3 before upgrading; if bref is locked by another package, you are stuck on this package's 1.x.queue:work. Lambda gives you one invocation per event; the package's consumer handles one batch and returns. Any pattern relying on a warm daemon (in-memory caching between jobs, --sleep, --daemon assumptions) doesn't apply.batchSize: 1 on anything non-idempotent.LOG_CHANNEL=stderr and read CloudWatch; local storage/logs writes are lost and slow on Lambda.aws sqs send-message), they won't match Laravel's job envelope. Either publish through Laravel's queue API or confirm the package's handling of foreign payloads in the README before relying on it.sqs connection, (2) is the message in the queue or already consumed, (3) CloudWatch for the invocation, (4) failed_jobs row, (5) DLQ message count. Those five cover almost every case.composer update.How can I help you explore Laravel packages today?