PHPackages                             smmehdisharifi/laravel-msgpack - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. smmehdisharifi/laravel-msgpack

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

smmehdisharifi/laravel-msgpack
==============================

Laravel integration for MessagePack

1.0.0(11mo ago)35MITPHPPHP ^8.1CI passing

Since Jun 4Pushed 11mo agoCompare

[ Source](https://github.com/smmehdisharifi/laravel-msgpack)[ Packagist](https://packagist.org/packages/smmehdisharifi/laravel-msgpack)[ RSS](/packages/smmehdisharifi-laravel-msgpack/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel Msgpack
===============

[](#laravel-msgpack)

[![Latest Version on Packagist](https://camo.githubusercontent.com/43c6914dfec22c43ced4146afa6abe57d86688a1dbf0ce3bb6e2562c1a8451f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6d65686469736861726966692f6c61726176656c2d6d73677061636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smmehdisharifi/laravel-msgpack)[![Total Downloads](https://camo.githubusercontent.com/a9f902dd6cce8e9fe11fefb85a1e01ad24817201b2b4744c8c47184ff71e2f01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736d6d65686469736861726966692f6c61726176656c2d6d73677061636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smmehdisharifi/laravel-msgpack)[![Tests](https://github.com/smmehdisharifi/laravel-msgpack/actions/workflows/run-tests.yml/badge.svg)](https://github.com/smmehdisharifi/laravel-msgpack/actions/workflows/run-tests.yml)

Laravel Msgpack brings [MessagePack](https://msgpack.org/) support to Laravel for fast and compact binary data serialization.
It adds encoding/decoding utilities, response macros, and a middleware for API requests and responses using Msgpack.

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

[](#-features)

- Encode/Decode any PHP/Laravel data
- `response()->msgpack()` macro like `response()->json()`
- `msgpack` middleware to auto-handle request/response
- Easy Laravel integration via Service Provider
- Works with Laravel &gt;= 9.x

📚 Table of Contents
-------------------

[](#-table-of-contents)

- [📦 Installation](#-installation)
- [⚙️ Configuration (Optional)](#%EF%B8%8F-configuration-optional)
- [🧠 Basic Usage](#-basic-usage)
    - [Encode / Decode](#encode--decode)
    - [Response Macro](#response-macro)
    - [Middleware](#middleware)
- [🧰 Requirements](#-requirements)
- [📄 License](#-license)
- [✨ Credits](#-credits)
- [🤝 Contributing](#-contributing)
- [📦 Packagist](#-packagist)

🧰 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- Laravel 9.x or newer

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

[](#-installation)

```
composer require smmehdisharifi/laravel-msgpack
```

Requires PHP 8.1+ and Laravel 9.x or newer

⚙️ Configuration (Optional)
---------------------------

[](#️-configuration-optional)

If you want to publish the config file:

```
php artisan vendor:publish --tag=msgpack-config
```

🧠 Basic Usage
-------------

[](#-basic-usage)

### Encode / Decode

[](#encode--decode)

```
use Msgpack;

$data = ['name' => 'Laravel', 'type' => 'framework'];

$packed = Msgpack::encode($data);
$unpacked = Msgpack::decode($packed);
```

### Response Macro

[](#response-macro)

```
return response()->msgpack([
    'message' => 'Hello from Msgpack!',
]);
```

Sends a binary response with header:

```
Content-Type: application/x-msgpack
```

### Middleware

[](#middleware)

Register middleware in `app/Http/Kernel.php`:

```
protected $middlewareAliases = [
    'msgpack' => \SmMehdiSharifi\LaravelMsgpack\Middleware\MsgpackMiddleware::class,
];
```

Apply it to routes:

```
Route::middleware('msgpack')->post('/api/data', function (Request $request) {
    return response()->msgpack(['received' => $request->all()]);
});
```

🧪 Testing
---------

[](#-testing)

This package includes PHPUnit tests using Orchestra Testbench. To run tests:

```
composer install
./vendor/bin/phpunit
```

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

✨ Credits
---------

[](#-credits)

Made with ❤️ by [Mehdi Sharifi](https://github.com/smmehdisharifi)

Inspired by Laravel’s elegant API response system.

🤝 Contributing
--------------

[](#-contributing)

Feel free to fork this repo and submit pull requests.

- Found a bug? [Open an issue](https://github.com/smmehdisharifi/laravel-msgpack/issues)
- Have a feature idea? Let’s discuss it!
- PRs with tests are welcome 🙌

📦 Packagist
-----------

[](#-packagist)

View on Packagist:

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance51

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

343d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6aa63eb66d842a164d17a2cb67fca543d487b41bc3f565863747686949742305?d=identicon)[winkers](/maintainers/winkers)

---

Top Contributors

[![smmehdisharifi](https://avatars.githubusercontent.com/u/24722498?v=4)](https://github.com/smmehdisharifi "smmehdisharifi (1 commits)")

---

Tags

laravelmsgpackphp

### Embed Badge

![Health badge](/badges/smmehdisharifi-laravel-msgpack/health.svg)

```
[![Health](https://phpackages.com/badges/smmehdisharifi-laravel-msgpack/health.svg)](https://phpackages.com/packages/smmehdisharifi-laravel-msgpack)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[illuminate/cookie

The Illuminate Cookie package.

224.3M122](/packages/illuminate-cookie)

PHPackages © 2026

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