Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs on 64-bit machines #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


test:
phpunit --coverage-text --whitelist=msgpack.php msgpackTest.php

clean:
rm -f *~
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
MessagePack PHP functions
=============

The purpose of this project is to implement [MessagePack](http://msgpack.org/) serialization using only PHP. This might be useful for someone unable to install php-modules, or using [HipHop](https://github.com/facebook/hiphop-php) to compile PHP as C++.
The purpose of this project is to implement [MessagePack](http://msgpack.org/) serialization using only PHP. It aims to work even on very old versions of PHP, such as found in many long-term support server distros, while supporting the modern str8/bin8/bin16/bin32 additions to msgpack.

Additions
-----

- Supports decoding and encoding str8 and bin8/16/32 types.
- By analogy to the python implementation, msgpack_unpackb accepts $raw parameter determining handling of str types (default: $raw=True).
- By analogy to the python implementation, msgpack_packb accepts $use_bin_type parameter determining use of bin types (default: $use_bin_type=False).
- PHP has no concept of bytes vs unicode strings, so msgpack_packb also accepts $force_str_as_bin parameter forcing the use of bin types event for
strings that are valid utf-8.

Caveats
-----

- Only msgpack_pack() and msgpack_unpack() are defined.
- It's only tested on [little endian](http://en.wikipedia.org/wiki/Endianness) architecture, but should work on big endian as well, please test it if able.
- The uint64 and int64 types probably requires 64-bit systems to work
- Only msgpack_packb() and msgpack_unpackb() are defined.
- It's only tested on [little endian](http://en.wikipedia.org/wiki/Endianness) architecture, but should work on big endian as well.
- It uses is_x() to select the type, do your casts before using the functions
- Unlike the official lib you can't pack objects. If you know how to do this please fork.
- Unlike the official lib you can't pack objects. Feel free to submit a pull request to add this functionality.
- It will always pack integers into the least amount of bits possible, and will prefer unsigned.

- It does not support ext/fixext types.

Benchmark
-----
Expand Down Expand Up @@ -55,4 +63,4 @@ status : OK OK OK OK OK
serialize : 0.0199 (100%) 0.0481 (242%) 0.0306 (153%) 0.0148 ( 74%) 0.8513 (4285%) 0.0763 ( 383%)
unserialize: 0.0231 (100%) 0.0583 (252%) 0.0202 ( 87%) 0.0248 (107%) 1.4168 (6134%) 0.3156 (1366%)
size : 406 (100%) 351 ( 86%) 346 ( 85%) 351 ( 86%) 351 ( 86%) 351 ( 86%)
```
```
Loading