phpserialize
a port of the serialize and unserialize functions of php to python.
What it is and what it does
phpserialize is a Python port of PHP's serialize and unserialize functions, enabling bidirectional conversion between Python objects and PHP serialization format. It implements the standard Python serialization interface with `dumps`, `loads`, and file-like object support.
The package handles PHP's type system differences: lists become dicts (with integer keys), unicode strings are UTF-8 encoded by default, and None/floats/booleans are converted to PHP-compatible types. It also supports PHP object serialization through hooks and provides helper functions like `dict_to_list` and `dict_to_tuple` to recover Python data structures. Version 1.3 added Python 3 support using the 'surrogateescape' error handler for bytes/unicode handling.
Use it for:
- Deserialize PHP session data or cache stored in PHP format within a Python application
- Exchange structured data between PHP and Python services without JSON/XML conversion overhead
- Migrate or synchronize data from PHP applications to Python backends while preserving PHP object metadata
- Test PHP serialization logic in Python test suites by round-tripping PHP-serialized objects
- Parse WordPress or other PHP framework object data in Python analysis or migration tools
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Python objects to and from PHP serialization format, implementing the `dumps`/`loads` interface for cross-language data exchange.
Yes, but with caution. The package is stable for basic PHP serialization tasks and carries no known vulnerabilities, but it has been dormant since 2012 with minimal maintenance. Install if you have a specific need to interoperate with PHP serialized data and accept that bug fixes or Python version compatibility updates are unlikely. For new projects, consider whether JSON or another standard format would reduce coupling to PHP.
Install
phpserialize on PyPI
pip
pip install phpserializeuv
uv add phpserializepoetry
poetry add phpserializeInstalling phpserialize
Before you install
High install friction due to source-only distribution. Package is dormant since 2012 with no recent maintenance, though the repository shows a recent commit in 2024. No runtime dependencies.
License in practice
Licensed under BSD (permissive), allowing commercial and private use with minimal restrictions.
Quickstart
from phpserialize import dumps, loads
# Serialize a Python string
obj = dumps("Hello World")
print(loads(obj)) # 'Hello World'
# Handle lists (serialized as dicts in PHP)
from phpserialize import dict_to_list
result = dict_to_list(loads(dumps([1, 2, 3])))
print(result) # [1, 2, 3]
No Python version requirement specified; test compatibility with your target Python version before production use.
Verify before relying
- Whether the 2024 repository commit represents active maintenance or a one-off update
- Python 3 compatibility status beyond the version 1.3 changelog note
- Whether binary data handling via 'surrogateescape' is production-ready
Package facts
| License | UNKNOWN (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | dormant — 5,318 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 272,666/month — #8,207 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: phpserialize-1.3.tar.gz
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
php2jsonConverts PHP serialized strings to JSON format,…
permissive · top 15,000 on PyPI
serpentSerpent serializes Python objects to…
permissive · top 15,000 on PyPI
dynamodb-jsonConverts Python objects to and from DynamoDB's…
unclear · top 5,000 on PyPI
bloomfilter-pyImplements Bloom filters in Python with…
permissive · top 15,000 on PyPI
sexpdataParses and serializes S-expressions (Lisp-style…
permissive · top 15,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
telepathtelepath serializes Python objects to…
permissive · top 5,000 on PyPI
json-fixPatches Python's built-in `json` module to…
permissive · top 15,000 on PyPI
amazon-ionParses and serializes Amazon Ion, a…
permissive · top 5,000 on PyPI
libconfReads and writes configuration files in…
permissive · top 15,000 on PyPI