Skip to main content
Build a consumer app that polls an SQS queue and writes every message to a file. You use Winter Boot for the application runtime and the Winter SQS module from Winter Modules for queue access. You test the whole flow locally with ElasticMQ, an SQS-compatible emulator.

Prerequisites

You need PHP 8.5 or later with the swoole and pcntl extensions. You also need Docker to run ElasticMQ and the AWS CLI to create the queue and send messages. Start ElasticMQ before you run the app:

Project structure

The sample uses this layout:

Install dependencies

Require the framework and the modules package:

Source files

Switch between the four source files. Each tab shows the exact file from the sample.
The single entry point. It points Winter Boot at the config directory and at the sample namespace.

Configuration

Switch between the two config files. application.yml enables the module, and sqs-config.yml defines the connection and consumer.
The full sample file registers SqsModule and sets the server and app identity:
See Configuration for every application.yml key.

Run the app

Create the queue, start the app, send a message, then check the output file. 1. Create the queue:
2. Start the application:
The SQS worker starts polling my-queue as soon as the app boots. 3. Send a message:
4. Verify consumption:
You see one line per consumed message, for example:

Next steps

  • Read the SQS module for producer APIs (SqsService), IAM-role setup, and consumer tuning (waitTimeSeconds, maxNumberOfMessages, visibilityTimeout).
  • Browse all Libraries when you need Kafka, S3, Redis, or Doctrine in the same app.