How jundayw/message-pack-codec works
MessagePackCodec is a PHP library for declaratively encoding and decoding binary records. The principal workflow begins with an application supplying data or binary plus a field schema to MessagePackCodec, which resolves each field’s type and context-dependent options, then invokes type-specific packing or unpacking and returns a message object. The tree also documents numeric, bit, string, BCD, and other byte-oriented field types; only selected implementations were sampled, so their internal wiring is shown at the shared type layer rather than inferred individually.
Main entry points: MessagePackCodec.php Codec orchestrator · Type.php Shared type engine · Format.php Binary formats · EncodeContext.php Encode context
Components 20
Codec API
- Codec orchestrator
src/MessagePackCodec.php - Message and bags
src/Message/Bag.php - Encoded message
src/Message/EncodeMessage.php - Decoded message
src/Message/DecodeMessage.php
Field Runtime
- Encode context
src/Context/EncodeContext.php - Decode context
src/Context/DecodeContext.php - Context contract
src/Contract/Context.php - Type contract
src/Contract/Type.php - Shared type engine
src/Concerns/Type.php
Binary Types
- Field type families
src/Type - String type
src/Type/StringType.php - Bit type
src/Type/BitType.php
Encoding Support
- Binary formats
src/Support/Format.php - Byte order
src/Support/Endian.php - Endian helpers
src/Support/Endian.php
Other components
- PHP application
- Data and schema
- Binary and schema
- Encoded bytes
- Decoded values
Connections 27
- PHP application → Codec orchestrator: calls encode/decode
- PHP application → Data and schema: supplies data
- PHP application → Binary and schema: supplies binary
- Data and schema → Codec orchestrator: passes fields
- Binary and schema → Codec orchestrator: passes fields
- Codec orchestrator → Encode context: creates context
- Codec orchestrator → Decode context: creates context
- Codec orchestrator → Field type families: instantiates configured
- Codec orchestrator → Shared type engine: resolves and invokes
- Field type families → Type contract: implements
- Shared type engine → Type contract: implements
- Shared type engine → Binary formats: packs by format
- Shared type engine → Encode context: resolves options
- Shared type engine → Decode context: resolves options
- String type → Shared type engine: extends
- Bit type → Shared type engine: extends
- String type → Binary formats: selects format
- Bit type → Binary formats: selects format
- Binary formats → Byte order: reports byte order
- Byte order → Endian helpers: defines order
- Encode context → Message and bags: stores input and options
- Decode context → Message and bags: stores options and schema
- Codec orchestrator → Encoded message: writes field results
- Codec orchestrator → Decoded message: writes field results
- Encoded message → Encoded bytes: returns bytes
- Decoded message → Decoded values: returns values
- Codec orchestrator → PHP application: returns message