Download the PHP package kafka/workflow without Composer

On this page you can find all versions of the php package kafka/workflow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package workflow

kafka/workflow

Laravel Kafka package — Transactional Outbox, Batch Relayer, Consumer Dispatcher với DLQ/EDL routing và Telegram alerting.

PHP Laravel


Yêu cầu

Thành phần Phiên bản
PHP ^8.2
Laravel 10 hoặc 11
librdkafka ≥ 1.0
ext-rdkafka (cài qua PECL)

ext-rdkafka là C extension, không thể cài qua Composer. Xem hướng dẫn bên dưới.


Cài đặt

Bước 1 — Cài librdkafka + ext-rdkafka

Package cung cấp sẵn 3 cách:

Cách A — Artisan command (sau khi đã composer require)

Cách B — Shell script (CI/CD, server, trước khi có Laravel)

Cách C — Composer scripts shortcut

Cách D — Docker (copy scripts/Dockerfile.example vào project của bạn)

OS được hỗ trợ tự động: macOS (Homebrew), Ubuntu/Debian (apt), Alpine (apk), RHEL/CentOS/Amazon Linux (yum/dnf).


Bước 2 — Cài package


Bước 3 — Publish config và migrate

Nếu không publish config, package dùng giá trị mặc định từ nội bộ.
Nếu không publish migrations, package tự load migrations — không cần publish nếu không cần customize.


Bước 4 — Thêm vào .env


PRODUCER

Producer có hai trách nhiệm duy nhất: ghi vào Outbox và Relay lên Kafka.
Không gọi Kafka trực tiếp từ request — không bao giờ.

Ghi một message (trong DB transaction)

Ghi nhiều message cùng topic (batch — một INSERT)

Ghi nhiều message với topic/event_type khác nhau

ProducerOptions — tuỳ chỉnh per-message, độc lập với core config

Chạy Relayer

Relayer đọc PENDING/FAILED records từ kafka_outbox và publish lên Kafka theo batch — một flush() duy nhất mỗi batch, group theo topic.

Dùng Laravel Scheduler:

Dùng Supervisor:


CONSUMER

Consumer không xử lý business logic. Package đảm nhiệm:

Cơ bản

Báo lỗi để package route đúng

Exception Hành động Commit offset?
TransientInfraException → DLQ topic + DB log + Telegram ❌ Không
PoisonPillException → EDL DB log + Telegram ✅ Có
Bất kỳ \Throwable nào khác → EDL DB log + Telegram ✅ Có
Duplicate event_id Bỏ qua silently ✅ Có

Hook onError (tuỳ chọn)

Tạo Artisan Command cho consumer

Chạy với Supervisor:


SERIALIZATION

Package hỗ trợ 2 driver, cùng interface — chuyển đổi chỉ cần đổi .env.

JSON (mặc định)

Wire format: JSON UTF-8 string. Không cần cấu hình thêm.


Avro Binary (Confluent wire format)

Wire format: [0x00][schema_id: 4 bytes][avro binary] — chuẩn Confluent.

Dependency: flix-tech/avro-php ^5.1 đã có sẵn trong composer.json require — không cần cài thêm.

Subject naming strategy:

Schema cache (giảm HTTP call xuống Registry):

Local schema files (không fetch từ Registry):


REDRIVE

Đẩy lại message bị lỗi từ kafka_failed_event_logs vào outbox để Relayer publish lại.

Status flow của kafka_failed_event_logs:


TELEGRAM ALERTING

Alert DLQ:

Alert EDL:


DATABASE TABLES

Package tạo 3 bảng với prefix kafka_ — không xung đột với schema của host project.

Bảng Mô tả
kafka_outbox Message chờ Relayer publish. status: PENDING → SENT / FAILED
kafka_processed_events Idempotency guard. event_id là primary key
kafka_failed_event_logs DLQ + EDL records. failure_type: DLQ / EDL

Publish migrations nếu cần customize:


ARTISAN COMMANDS

Command Mô tả
kafka:install Kiểm tra và cài librdkafka + ext-rdkafka
kafka:install --check Chỉ kiểm tra môi trường
kafka:install --force Cài không hỏi confirm
kafka:outbox-relay Relay outbox records lên Kafka (một lần)
kafka:outbox-relay --loop Relay liên tục (dùng với Supervisor)
kafka:outbox-relay --loop --interval=3 Loop mỗi 3 giây
kafka:redrive --type=dlq Redrive DLQ records vào outbox
kafka:redrive --type=edl Redrive EDL records vào outbox
kafka:redrive --dry-run Xem trước không thực hiện

CẤU TRÚC PACKAGE


FLOW TỔNG THỂ


LICENSE

MIT © Linh NQ


All versions of workflow with dependencies

PHP Build Version
Package Version
Requires flix-tech/avro-php Version ^5.1
php Version ^8.2
ext-rdkafka Version *
illuminate/console Version ^9.0|^10.0|^11.0
illuminate/database Version ^9.0|^10.0|^11.0
illuminate/http Version ^9.0|^10.0|^11.0
illuminate/support Version ^9.0|^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kafka/workflow contains the following files

Loading the files please wait ...