Skip to main content
Build an invoice-pricing app that turns checkout carts into invoices in background workers. You use Winter Boot for the application runtime and the Winter DTCE module from Winter Modules for distributed task execution. You test the whole flow locally with the shared queue and disk store, so no Docker or external service is needed.

Prerequisites

You need PHP 8.5 or later with the swoole and pcntl extensions.

Project structure

The sample uses this layout:

Install dependencies

Require the framework and the modules package:

Source files

Switch between the five 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 sets the shared-queue port, and dtce-config.yml defines the invoiceTotal task with its worker, disk store, and shared queue.
The full sample file registers DtceModule and sets the server and app identity. winter.queue.port is required by the shared queue used below:
See Configuration for every application.yml key.

Run the app

Start the app, price one order, settle a batch, then check the output file. 1. Start the application:
The DTCE workers start processing the invoiceTotal queue as soon as the app boots. 2. Price a single order:
You get the invoice breakdown back, for example:
3. Settle a batch of orders as one job:
You get one invoice per order in the job, for example:
4. Verify the worker output:
You see one line per priced order, for example:

Next steps

  • Read the DTCE module for the async APIs (addTask, addJob, taskStatus, stopTask), persistent backends, and full configuration.
  • Browse all Libraries when you need Kafka, SQS, Redis, or Doctrine in the same app.