开发者

Protocol Buffer for PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
开发者_运维百科

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this question

What are the avaliable libraries for using protobuf in PHP?


Protocol_Buffer_for_PHP

Last updated in May 2009

Implementing the Google "Protocol Buffer" for PHP, include parsing ...

Issue list: http://code.google.com/p/pb4php/issues/list

Protobuf-PHP

Last updated in April 2011

Protobuf for PHP is an implementation of Google's Protocol Buffers for the PHP language, supporting its binary data serialization and including a protoc plugin to generate PHP classes from .proto files.

Great effort has been put into generating PHP files that include all sort of type hints to aide IDE's with autocompletion. Therefore, it can not only be used to communicate with Protocol Buffers services but also as a generation tool for data objects no matter what the final serialization is.

Example:

$person = new Tutorial\Person();
$person->name = 'DrSlump';
$person->setId(12);

$book = new Tutorial\AddressBook();
$book->addPerson($person);

// Use default codec
$data = $book->serialize();

// Use custom codec
$codec = new \DrSlump\Protobuf\Codec\Binary();
$data = $codec->encode($book);
// ... or ...
$data = $book->serialize($codec);

protoc-gen-php

Last updated December 05, 2010

This is a PHP Google Protocol Buffer Generator Plugin for protoc. It generates PHP code from a .proto file.


There is also https://github.com/drslump/Protobuf-PHP

Last updated December 2013.

Requirements (from the Github page):

  • PHP 5.3
  • Pear's Console_CommandLine (for the protoc wrapper tool)
  • Google's protoc compiler version 2.3 or above
  • GMP or BC Math extensions ¹

    ¹ Only needed for negative values in int32, int64 or fixed64 types. See the known issues section.


If performance is your concern you might try PHP Protobuf.

It is PHP Protocol Buffers implementation written as an extension in C. Even though it is C code has no external dependencies including original Google's implementation.

PHP Protobuf comes with quite complete documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜