Protobuf-PHP
Protobuf-PHP copied to clipboard
Problems Using Proto3 Timestamps
For the record, I'm using protobuf
v3.0.0
, php 5.6
and the composer
requirement for this library is
"require": {
"stanley-cheung/protobuf-php": "^0.6.0"
},
When I use the timestamp
well-known type from protobuf3, like so:
import 'google/protobuf/timestamp.proto';
message Foo {
google.protobuf.Timestamp bar = 1;
}
The messages are generated asphp
with the following syntax:
/**
* Get <bar> value
*
* @return \google\protobuf\Timestamp
*/
public function getBar(){
return $this->_get(6);
}
/**
* Set <bar> value
*
* @param \google\protobuf\Timestamp $value
* @return \Foo
*/
public function setBar(\google\protobuf\Timestamp $value){
return $this->_set(6, $value);
}
The issue I have is that there's no way for me to import the \google\protobuf\Timestamp
value into my namespace, as it isn't generated, so I can't actually call setBar()
, above.
Is there guidance for using the new well-known types in a particular way? Also, is there support for json
serialization of these types?