1. Go to this page and download the library: Download basho/protobuf library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
basho / protobuf example snippets
$foo = new Foo();
$foo->setBar(1);
$foo->setBaz('two');
$foo->appendSpam(3.0);
$foo->appendSpam(4.0);
$packed = $foo->serializeToString();
$parsedFoo = new Foo();
try {
$parsedFoo->parseFromString($packed);
} catch (Exception $ex) {
die('Oops.. there is a bug in this example, ' . $ex->getMessage());
}
$parsedFoo->dump();
$parsedFoo->reset();
git clone https://github.com/allegro/php-protobuf
cd php-protobuf
php protoc-gen-php.php foo.proto
$foo = new Foo();
$foo->setBar(1);
$foo->setBaz('two');
$foo->appendSpam(3.0);
$foo->appendSpam(4.0);
$packed = $foo->serializeToString();
$foo->clear();
try {
$foo->parseFromString($packed);
} catch (Exception $ex) {
die('Oops.. there is a bug in this example');
}
$foo->dump();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.