Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Msgpack Laravel Package

rybakit/msgpack

Pure PHP implementation of the MessagePack serialization format, fully compliant with the latest spec. Supports streaming unpacking, unsigned 64-bit integers, custom object types and extensions, with good performance and full test coverage.

View on GitHub
Deep Wiki
Context7

rybakit/msgpack is a pure PHP implementation of the MessagePack binary serialization format—a compact, fast alternative to JSON for exchanging data between applications. It offers simple APIs through a Packer instance or MessagePack::pack() for encoding values, and supports streaming unpacking for handling large payloads and network streams.

  • Fully compliant with the latest MessagePack specification
  • Supports streaming unpacking and unsigned 64-bit integer handling
  • Custom types via type objects, transformers, and extensions (including Timestamp)
  • Fully tested and relatively fast
Frequently asked questions about Msgpack
How do I install rybakit/msgpack in a Laravel application?
Install it with composer require rybakit/msgpack. The library is framework-agnostic, so in Laravel you can use Packer and Unpacker directly or bind a shared packer/unpacker in a service provider. There is no built-in Laravel service provider to publish.
Is rybakit/msgpack compatible with Laravel 10 and 11?
The package has no known conflicts with Laravel 10 or 11. It is pure PHP and does not require the msgpack C extension, but you should test on PHP 8.2+ in your application. Because it is framework-agnostic, Laravel compatibility mainly depends on your PHP version and how you wrap it.
Can I use MessagePack instead of JSON for Laravel API responses?
Yes, you can use it for internal API payloads where compact binary data matters. MessagePack is smaller and faster than JSON but not human-readable, so it is a better fit for service-to-service contracts than public browser APIs. You will need to set the correct content type and ensure clients can decode MessagePack.
How do I use MessagePack for Laravel queue jobs or cache payloads?
You can serialize complex job or cache payloads with Packer before handing them to Laravel's queue or cache drivers. This can reduce storage overhead for nested objects or binary data, but cache and queue backends must accept binary strings. For custom storage drivers, decode with Unpacker when reading values back.
How do I serialize Carbon dates or UUIDs with rybakit/msgpack?
Register explicit type transformers or extensions for domain types such as Carbon or UUID. The package supports object serialization and custom types, including timestamps, but it will not guess how to encode your DTOs by default. Plan a versioning or backward-compatibility strategy before adding new custom types to stored payloads.
How does rybakit/msgpack handle 64-bit integers?
The package supports unsigned 64-bit integer handling through unpacking options. PHP integers overflow beyond 64-bit, so configure BIGINT_AS_GMP or BIGINT_AS_DEC when you need to preserve large values. Test edge cases with your actual data range before relying on default integer behavior.
What is streaming unpacking in rybakit/msgpack and when should I use it?
Streaming unpacking is useful when you receive MessagePack data in chunks rather than as one complete payload. BufferUnpacker supports chunked unpacking, which helps with large or streamed payloads. In Laravel HTTP handling, you may need middleware or custom request parsing to feed binary streams correctly.
How should I handle PackingFailedException and UnpackingFailedException in Laravel?
Catch PackingFailedException and UnpackingFailedException around pack and unpack calls. In Laravel, wrap them or report them through the exception Handler so clients get consistent error responses and logs include context. Avoid letting raw binary decoding failures surface as generic 500 errors in production.
Is rybakit/msgpack faster than JSON, and what are the trade-offs?
The package is relatively fast, and MessagePack is generally more compact and faster than JSON for serialization and deserialization. The trade-off is that payloads are binary and not human-readable, which complicates debugging and manual inspection. Benchmark with your real Laravel payloads before replacing JSON broadly.
How do I debug MessagePack payloads or test them in CI?
MessagePack has no built-in pretty-printing, so use var_export, custom debug helpers, or Laravel Telescope/debugbar macros to inspect payloads. For CI, include round-trip tests and fuzz testing of pack/unpack behavior with representative and malformed payloads. The package is fully tested, but your application-specific custom types still need coverage.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route