MessagePack + PHP
今回使いたい基本的なツールを一通り確認しておく。
http://msgpack.org/
$ mkdir msgpack && cd msgpack
$ git clone https://github.com/msgpack/msgpack-php.git .
Initialized empty Git repository in /opt/installer/php/msgpack/.git/
remote: Counting objects: 514, done.
remote: Compressing objects: 100% (135/135), done.
remote: Total 514 (delta 404), reused 484 (delta 374)
Receiving objects: 100% (514/514), 158.56 KiB | 133 KiB/s, done.
Resolving deltas: 100% (404/404), done.
$ ls
CREDITS config.m4 msgpack_convert.c package.xml
ChangeLog config.w32 msgpack_convert.h php-msgpack.spec
EXPERIMENTAL msgpack msgpack_errors.h php_msgpack.h
LICENSE msgpack.c msgpack_pack.c test_normal.php
README.md msgpack.php msgpack_pack.h test_streaming.php
bench msgpack_class.c msgpack_unpack.c tests
benchmark.php msgpack_class.h msgpack_unpack.h
$ git clone https://github.com/msgpack/msgpack-php.git .
Initialized empty Git repository in /opt/installer/php/msgpack/.git/
remote: Counting objects: 514, done.
remote: Compressing objects: 100% (135/135), done.
remote: Total 514 (delta 404), reused 484 (delta 374)
Receiving objects: 100% (514/514), 158.56 KiB | 133 KiB/s, done.
Resolving deltas: 100% (404/404), done.
$ ls
CREDITS config.m4 msgpack_convert.c package.xml
ChangeLog config.w32 msgpack_convert.h php-msgpack.spec
EXPERIMENTAL msgpack msgpack_errors.h php_msgpack.h
LICENSE msgpack.c msgpack_pack.c test_normal.php
README.md msgpack.php msgpack_pack.h test_streaming.php
bench msgpack_class.c msgpack_unpack.c tests
benchmark.php msgpack_class.h msgpack_unpack.h
# phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
# ./configure && make && make install
Installing shared extensions: /usr/lib64/php/modules/
Installing header files: /usr/include/php/
# echo “extension=msgpack.so” > /etc/php.d/msgpack.ini
# php test_normal.php
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
string(10) “0x93010203″
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
msgpack.iniだけ自分で書いた以外は何もしていません。
問題なくインストール出来たようです。
サーバーのバージョンとか
# php -v
PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
# cat /etc/redhat-release
CentOS release 6.2 (Final)
# arch
x86_64
msgpack.jsもあるので
そのまま使う場合はjson使うのやめてクライアント側もmessagepackで良いのかなと