GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - msgpack/msgpack-php: msgpack.org[PHP]

BranchesTags
Open more actions menu

Latest commit

 

History

418 Commits
418 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
bench
bench
 
 
msgpack
msgpack
 
 
scripts
scripts
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
CREDITS
CREDITS
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
config.m4
config.m4
 
 
config.w32
config.w32
 
 
gen_travis_yml.php
gen_travis_yml.php
 
 
msgpack-stub.php
msgpack-stub.php
 
 
msgpack.c
msgpack.c
 
 
msgpack_class.c
msgpack_class.c
 
 
msgpack_class.h
msgpack_class.h
 
 
msgpack_convert.c
msgpack_convert.c
 
 
msgpack_convert.h
msgpack_convert.h
 
 
msgpack_errors.h
msgpack_errors.h
 
 
msgpack_pack.c
msgpack_pack.c
 
 
msgpack_pack.h
msgpack_pack.h
 
 
msgpack_unpack.c
msgpack_unpack.c
 
 
msgpack_unpack.h
msgpack_unpack.h
 
 
package.xml
package.xml
 
 
php_msgpack.h
php_msgpack.h
 
 

Repository files navigation

Msgpack for PHP

Build Status

This extension provides an API for communicating with MessagePack serialization.

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages just like JSON. But unlike JSON, it is very fast and small.

Requirement

  • PHP 7.0 +

Install

Install from PECL

Msgpack is a PECL extension, thus you can simply install it by:

pecl install msgpack

Compile Msgpack from source

/path/to/phpize
./configure --with-php-config=/path/to/php-config
make && make install

Example

<?php
$data = array(0 => 1, 1 => 2, 2 => 3);
$msg = msgpack_pack($data);
$data = msgpack_unpack($msg);

Advanced Example

<?php
$data = array(0 => 1, 1 => 2, 2 => 3);
$packer = new \MessagePack(false);
// ^ same as $packer->setOption(\MessagePack::OPT_PHPONLY, false);
$packed = $packer->pack($data);

$unpacker = new \MessagePackUnpacker(false);
// ^ same as $unpacker->setOption(\MessagePack::OPT_PHPONLY, false);
$unpacker->feed($packed);
$unpacker->execute();
$unpacked = $unpacker->data();
$unpacker->reset();

Advanced Streaming Example

<?php
$data1 = array(0 => 1, 1 => 2, 2 => 3);
$data2 = array("a" => 1, "b" => 2, "c" => 3);

$packer = new \MessagePack(false);
$packed1 = $packer->pack($data1);
$packed2 = $packer->pack($data2);

$unpacker = new \MessagePackUnpacker(false);
$buffer = "";
$nread = 0;

//Simulating streaming data :)
$buffer .= $packed1;
$buffer .= $packed2;

while(true) {
   if($unpacker->execute($buffer, $nread)) {
       $msg = $unpacker->data();

       var_dump($msg);

       $unpacker->reset();
       $buffer = substr($buffer, $nread);
       $nread = 0;
       if(!empty($buffer)) {
            continue;
       }
   }
   break;
}

Resources

  • msgpack

About

msgpack.org[PHP]

Resources

Readme
BSD-3-Clause license
Activity
Custom properties

Stars

788 stars

Watchers

59 watching

Forks

119 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.