PHP code example of haoyanfei / protobuf-php
1. Go to this page and download the library: Download haoyanfei/protobuf-php 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/ */
haoyanfei / protobuf-php example snippets
ump\Protobuf::autoload();
$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);