2017 © Pedro Peláez
 

library php-simple-protobuf

image

ndunks/php-simple-protobuf

  • Friday, May 11, 2018
  • by ndunks
  • Repository
  • 1 Watchers
  • 1 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

php-simple-protobuf

PHP Implementation of Google Protocol Buffers - Simple Protobuf implementation for PHP without install/compile PHP extension - Support to compile proto 2 files without use any binary/executable - Support group type field, (*1)

About Protobuf

Protocol Buffers (a.k.a., protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. You can find protobuf's documentation on the Google Developers site., (*2)

Getting started

Requirements

  • PHP 5.6 or above
  • php-json extension (for json serializer)

Installation

Install with composer., (*3)

# add ndunks/php-simple-protobuf entry to your composer.json
{
    "require": {
        "ndunks/php-simple-protobuf": "*"
    }
}

# install requirements composer
composer install

Usage

Compile proto 2 file to PHP Classes

Just execute php code on console in your project root dir, (*4)

vendor\bin\compiler.php.bat --out=<out-dir> --file=<proto-file>

Run the code

include 'vendor/autoload.php';
// Class Simple compiled from simple.proto (find on test/proto)
$obj = new Simple();
$obj->setName('user');
$obj->setAddress('Indonesia');
$obj->setAge(25);
$obj->toArray(); // as PHP Array
$obj->toJson(); // as JSON formated string

Example on Linux

Example Setup & installation on Linux make sure your php.ini (cli) has short_open_tag is On, (*5)

git clone https://github.com/ndunks/php-simple-protobuf
cd php-simple-protobuf
composer dump-autoload

You can skip composer install if you want to use it (not develop it) because this project not depend to any other composer library. Run this to compile example proto (on project dir), (*6)

# if output directory not exist, you must create it manualy
mkdir result
# Compile it
php bin/compiler.php --out=result --file=test/proto/simple.proto

Check on result dir, you will get Simple.php file generated from simple.proto, (*7)

The Versions

11/05 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mochamad Arifin

17/03 2018

v1.2

1.2.0.0

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mochamad Arifin

07/10 2017

1.1

1.1.0.0

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mochamad Arifin