mwx / serialized
PHP-serialized data without unserializing it: a structural parser, a serializer, search and replace, and a stdin filter
0.2.0
2026-09-24 10:29 UTC
Requires
- php: ^8.2
- mwx/lib: ^0.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-24 09:08:43 UTC
README
Handling of PHP-serialized data streams.
Owns the mwx\Serialized\ namespace prefix.
MIT, self-contained.
Parser— a structural parser for PHP-serialized data that never unserializes it: no object is instantiated, no__wakeup()orunserialize()handler runs.Parser::parseToObjectNotation()accepts a string or a stream resource (binary-safe) and returns a nested-array notation of the value; it covers the whole format (N;,b:,i:,d:,s:,a:,O:,C:,E:,R:/r:references). Malformed input throwsParseException; input that is merely a valid prefix of a payload throws the more specificIncompleteDataException, so streaming consumers can keep buffering.StdInFilter— aphp_user_filterthat validates PHP-serialized data flowing through stdin against the parser while passing it through (activate it viaStdIO::activateInputFilter(StdInFilter::class)).Serializer— re-emits the parser's object notation as a PHP-serialized payload, recomputing all byte lengths from the actual bytes; modify string values in the notation and serialize back to a consistent payload.SearchAndReplace— serialization-aware search and replace over strings or database rows: string values inside serialized payloads are replaced structurally (keys, member names, class names untouched, nested payloads recursed) and re-emitted with corrected lengths; plain strings are replaced as-is. Perl-style regex search terms are auto-detected, and consumer-driven callbacks can unwrap/re-wrap values (e.g. base64 columns) around the run.
Install
composer require mwx/serialized