1.2.1580. ext/protobuf¶
Extension Protobuf.
Protocol Buffers (a.k.a., protobuf) are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data.
<?php
// Example extracted from https://developers.google.com/protocol-buffers/docs/reference/php-generated
// given a simple message
//message Foo {}
/*
The protocol buffer compiler generates a PHP class called Foo. This class inherits from a common base class, Google\Protobuf\Internal\Message, which provides methods for encoding and decoding your message types, as shown in the following example:
*/
$from = new Foo();
$from->setInt32(1);
$from->setString('a');
$from->getRepeatedInt32()[] = 1;
$from->getMapInt32Int32()[1] = 1;
$data = $from->serializeToString();
try {
$to->mergeFromString($data);
} catch (Exception $e) {
// Handle parsing error from invalid data.
...
}
?>
See also Protocol Buffers, PHP Protocol Buffers and protobuf-php on packagist.
1.2.1580.1. Specs¶
Short name |
Extensions/Extprotobuf |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
With PHP 7.0 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |