PHPackages                             tsg/phpickle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tsg/phpickle

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tsg/phpickle
============

Python pickle format support for PHP

0.0.1(12y ago)126.8k↓27.8%PHP

Since May 22Pushed 12y ago3 watchersCompare

[ Source](https://github.com/thesilvervestgroup/Phpickle)[ Packagist](https://packagist.org/packages/tsg/phpickle)[ RSS](/packages/tsg-phpickle/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

```
Phpickle is a set of PHP classes that allow you to read and write the python
pickle format. It is useful for integrating python and php applications together,
for example to read django session data from a php application.

==============Basic usage:

----
$data = phpickle::loads($pickled_string);
---

If you want to unpickle from something that can be treated as a php stream, then:

----
$data = phpickle::load_stream("pickled_file.pickle");
$data = phpickle::load_stream("http://www.pickler.com/mydata");
// and others
---

If you want to unpickle data that was stored by the default django session handler, then:

----
$data = phpickle::loads_django_session($data_from_django_session_db);
---

If you want to pickle data, then:

---
$string = phpickle::dumps($data_to_pickle);
---

===============Current status:

Well, unpickling simple types, lists, tuples, dicts, ints, double, strings works.
Unpickling class instances also works, but of course the instances are not the same
as the ones in python. Instead stdClass instances are created, with all the data
properties that are in the pickle and a few extra ones as well:

$inst->__python_class__ = "__main__.test";
$inst->__python_construct_args__ = array();

__python_class__ is the package.class name for the python class that this instance represents.
__python_construct_args__ are the contructor arguments for creating the class instance in python.

Of course, referencing really python specific things, line REDUCE op that gives it's
argument to a python method to produce a result cannot be supported.

Pickling support is there for simple types and arrays. Experimental support for
objects is also there. Pickling back from previously unpickled data should produce
the same result most of the time, but needs better test coverage.

===============Code setup:

tests folder has phpunit based tests for some of the modules.

Pickle is a very simple stack based language, the interpreter is in
phpickle_unpickle.php and the read/write handlers for different opcodes are
in the phpickle_op_handlers.pck. To generate the interpreter files, run
make gen, that will generate phpickle_gen_read_ops.php and phpickle_gen_write_ops.php

To debug unpickling, call phpickle_unpickler->set_debug(true) and in the read
handler code, just to if ($debug). In the handler code, you can read data from the
$stream, using phpickle_stream methods and push results into $stack that is a
phpickle_stack instance. $memo is for memorizing things.
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4380d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6235f38b98a4836da0f6ae3a3ea8c805df0d8f75deae002b42612db97c4e2240?d=identicon)[silvervest](/maintainers/silvervest)

---

Top Contributors

[![terryf](https://avatars.githubusercontent.com/u/164401?v=4)](https://github.com/terryf "terryf (11 commits)")

### Embed Badge

![Health badge](/badges/tsg-phpickle/health.svg)

```
[![Health](https://phpackages.com/badges/tsg-phpickle/health.svg)](https://phpackages.com/packages/tsg-phpickle)
```

###  Alternatives

[ybazli/faker

Persian fake data package for laravel

7338.8k1](/packages/ybazli-faker)[hnassr/nova-key-value

A Laravel Nova field.

197.0k](/packages/hnassr-nova-key-value)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
