PHPackages                             memran/marwa-envelop - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. memran/marwa-envelop

ActiveLibrary[HTTP &amp; Networking](/categories/http)

memran/marwa-envelop
====================

Transport-agnostic message envelope with fluent builder for Kafka/WebSocket/etc.

v2.0.0(1mo ago)0211MITPHPPHP ^8.2

Since Aug 8Pushed 9mo agoCompare

[ Source](https://github.com/memran/marwa-envelop)[ Packagist](https://packagist.org/packages/memran/marwa-envelop)[ RSS](/packages/memran-marwa-envelop/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (1)

Marwa Envelop
=============

[](#marwa-envelop)

[![Latest Version on Packagist](https://camo.githubusercontent.com/426e1312413b23734d81474a2bbb63ab2f82006525c18a0b1148722c6a0e671d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d656d72616e2f6d617277612d656e76656c6f702e737667)](https://packagist.org/packages/memran/marwa-envelop)[![Downloads](https://camo.githubusercontent.com/4c115345158f7e08f7b8602e0f4a2ad39d1309346366c75a4439b2ac8bd3eafd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d656d72616e2f6d617277612d656e76656c6f702e737667)](https://packagist.org/packages/memran/marwa-envelop)[![License](https://camo.githubusercontent.com/479071cf8ffa48658e9719ba05b6099f132b917c9ef1cd648fdb91bc8151a05e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d656d72616e2f6d617277612d656e76656c6f702e737667)](LICENSE)

**Transport-agnostic, structured message wrapper** for PHP — ideal for Kafka, WebSocket, MQTT, log pipelines, or chat protocols.

---

🚀 Features
----------

[](#-features)

- 📦 PSR-compliant and lazy-loaded
- 💬 Works with strings, arrays, files, and links
- 🔐 Optional HMAC signing with TTL expiry
- 🔁 Compress/gzip for efficient transport
- 🔗 Attachments and file linking
- 🧱 Chainable message builder syntax
- 🧪 Ready for WebSocket, Kafka, SQS, Laravel Queue, MQTT, etc.

---

📸 Screenshot
------------

[](#-screenshot)

> Message structure as decoded from Envelop JSON:

```
{
  "id": "2dd0faca-499a-42de-a274-a458b12dc1cf",
  "type": "chat.message",
  "sender": "user:123",
  "receiver": "user:456",
  "body": "Hello World!",
  "headers": {
    "x-room": "demo"
  },
  "signature": "..."
}

```

---

📦 Installation
--------------

[](#-installation)

```
composer require memran/marwa-envelop
```

---

🛠 Usage Example
---------------

[](#-usage-example)

### ✉️ Build and Send Message

[](#️-build-and-send-message)

```
use Marwa\Envelop\EnvelopBuilder;

$msg = EnvelopBuilder::start()
    ->type('chat.message')
    ->sender('user:123')
    ->receiver('user:456')
    ->header('x-room', 'demo')
    ->body('Hello world!')
    ->ttl(60)
    ->sign('super-secret-key')
    ->build();

// Send over Kafka, WebSocket, etc.
$wire = $msg->toJson();
```

---

### 📬 Decode and Read Message

[](#-decode-and-read-message)

```
use Marwa\Envelop\Envelop;

$received = Envelop::fromJson($wire);

if ($received->isExpired()) {
    throw new \Exception("Message expired");
}

if (!$received->checkSignature('super-secret-key')) {
    throw new \Exception("Invalid signature");
}

echo $received->body; // "Hello world!"
```

---

### 📁 Attach File

[](#-attach-file)

```
$msg = EnvelopBuilder::start()
    ->type('chat.file')
    ->sender('u:1')
    ->receiver('u:2')
    ->attach('/path/to/image.jpg')
    ->build();
```

---

### 🔗 Link to Remote File

[](#-link-to-remote-file)

```
$msg = EnvelopBuilder::start()
    ->type('file.link')
    ->sender('u:1')
    ->receiver('u:2')
    ->link('https://example.com/my.pdf', [
        'name' => 'My Document',
        'size' => '2MB'
    ])
    ->build();
```

---

🧩 Ideal Use Cases
-----------------

[](#-ideal-use-cases)

- WhatsApp-style chat systems
- Kafka or MQTT message brokers
- WebSocket messaging with TTL
- Distributed logging pipelines
- Task queues with metadata (e.g. Laravel, Symfony)

---

🔖 Stable Releases
-----------------

[](#-stable-releases)

VersionNotes`v1.0.0`Initial stable release 🚀---

📝 License
---------

[](#-license)

MIT © [Mohammad Emran](https://github.com/memran)

---

🧠 Keywords
----------

[](#-keywords)

- kafka
- websocket
- envelope
- message structure
- event-driven
- php builder
- logging
- transport agnostic
- HMAC
- json message
- file attachment
- laravel queue

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~235 days

Total

2

Last Release

39d ago

Major Versions

v1.0.0 → v2.0.02026-03-31

PHP version history (2 changes)v1.0.0PHP &gt;=8.1

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cf906a31a250a940314fe42f8a18f449647bfe18095457350ff0081cf8dd3c2?d=identicon)[memran](/maintainers/memran)

---

Top Contributors

[![memran](https://avatars.githubusercontent.com/u/7415198?v=4)](https://github.com/memran "memran (11 commits)")

---

Tags

phpwebsocketmessagingmqttkafkaenvelope

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/memran-marwa-envelop/health.svg)

```
[![Health](https://phpackages.com/badges/memran-marwa-envelop/health.svg)](https://phpackages.com/packages/memran-marwa-envelop)
```

###  Alternatives

[centrifugal/phpcent

PHP library to communicate with Centrifugo HTTP API

1822.3M4](/packages/centrifugal-phpcent)[openswoole/core

Openswoole core library

181.1M32](/packages/openswoole-core)[basement-chat/basement-chat

Add a real-time chat widget to your Laravel application.

4983.9k](/packages/basement-chat-basement-chat)[hyperf/websocket-server

A websocket server library for Hyperf.

12488.7k25](/packages/hyperf-websocket-server)[swoft/websocket-server

swoft websocket server component

16134.1k3](/packages/swoft-websocket-server)[hemiframe/php-websocket

PHP WebSocket server and client library

4911.0k](/packages/hemiframe-php-websocket)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
