rybakit/msgpack
Pure PHP MessagePack serializer. Fully compliant with the latest spec, supports streaming unpacking, unsigned 64-bit integers, object serialization via custom types/extensions, and is well tested with good performance. Install via Composer; pack/unpack easily.
Install via Composer: composer require rybakit/msgpack. Start with basic packing/unpacking using MessagePack::pack($value) and MessagePack::unpack($packed). The default behavior handles common PHP types automatically — arrays become MessagePack arrays or maps depending on keys, strings become UTF-8 str by default. First practical use case: serialize small PHP arrays/objects for caching or inter-process communication (e.g., Redis) where compact binary format improves performance over JSON.
Map, Bin, or packMap()/packArray() to avoid auto-detection overhead and ensure deterministic serialization (e.g., when schema matters for deserialization).BufferUnpacker with append()/tryUnpack() for network sockets, file streaming, or Redis streams where messages arrive incrementally.UnpackOptions::BIGINT_AS_STR (default), BIGINT_AS_GMP, or BIGINT_AS_DEC when handling 64-bit unsigned IDs (e.g., from databases or APIs).CanBePacked interface for domain objects you control; use TypeTransformer (e.g., StreamTransformer) for external types like resources or classes you cannot modify.TimestampExtension to preserve nanosecond precision across DateTime-like needs, or use the built-in Timestamp class with MessagePack::pack(Timestamp::now()).PackOptions::FORCE_STR | PackOptions::FORCE_FLOAT32) to bypass auto-detection when data types are known in advance — especially useful in tight loops or high-throughput pipelines.[1 => 'a', 3 => 'b']) auto-pack as map. Ensure consumers expect maps, or force with PackOptions::FORCE_ARR/FORCE_MAP.PackOptions::FORCE_BIN, strings like "abc\x00" might be auto-detected as bin — test edge cases to avoid unintended type coercion.BIGINT_AS_GMP and BIGINT_AS_DEC require PHP extensions to be installed — failures may surface only in production if dev环境 lacks them.tryUnpack() may return empty [] even when more data is pending — only check for non-empty return to process complete messages.unpackExt() and inspect Ext object’s type code and data to troubleshoot malformed or unexpected binary payloads. Also enable strict error handling by catching PackingFailedException/UnpackingFailedException.How can I help you explore Laravel packages today?