HookFrame

Evandro Veloso Gomes
Published

0
  • Project creator

🎣 HookFrame – A Simple Webhook‐Processing Framework
HookFrame

Minimal, flexible, and queue-ready.

A lightweight PHP framework for receiving, queuing, and processing webhooks with retry support using RabbitMQ. Designed for extensibility, resilience, and simplicity—no assumptions about the payload.

Receives HTTP webhooks via webhook.php
Publishes them to RabbitMQ
Processes messages with a chain of handlers (ExampleHandler)
Supports automatic retries on handler failure

🚀 Features

Generic Webhook Receiver: Accepts any HTTP request.
RabbitMQ Integration: Durable queues, manual ACK/NACK, persistent messages.
Chain-of-Responsibility: Wire up multiple handlers to filter, transform, or process envelopes.
Retry Logic: Automatic requeueing with _retry counter and configurable RETRY_LIMIT.
No Payload Assumptions: Handlers decide how to parse payload.
PSR-4 Autoload: Drop your classes in classes/ and follow the Classes\ namespace.
Test Suite: Unit test for handler logic and full retry-flow simulation.

📦 Installation

git clone https://www.twine.net/signin
cd HookFrame
composer install
composer dump-autoload
cp .env.example .env

edit .env as needed

🔗 Architecture

HandlerInterface

interface HandlerInterface {
public function setNextHandler(HandlerInterface $handler): HandlerInterface;
public function handle(array $envelope): void;
}

Webhook Receiver
    Publishes to RabbitMQ.

ExampleHandler

🔁 Retry Logic

When a handler (e.g. ExampleHandler) throws an exception, the consumer should:

ACK the current message (to remove it).
Increment the _retry field in the JSON envelope.
Re-publish the envelope if _retry <= RETRY_LIMIT.
Discard (ACK without requeue) once _retry > RETRY_LIMIT.

⚙️ Configuration

You can configure via .env or system environment variables (getenv()).

.env file (example)

RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USER=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_QUEUE=queue_example

RETRY_LIMIT=3