Reputation: 17648
Related: Apache Thrift: Serializing data
Hi guys : I am noting that the PHP thrift extensions don't appear to have a TFileTransport class. This leads me to wonder : what is the mechanism for writing a thrift object to a FILE in PHP ?
Unfortunately, available documentation is focused on the client/server model for using thrift : but I need to use PHP to serialize binary thrift files on disc, which contain a stream of thrift objects.
Upvotes: 3
Views: 857
Reputation: 4392
Try extending TPhpStream by overriding:
private static function inStreamName() {
if (php_sapi_name() == 'cli') {
return 'php://stdin';
}
return 'php://input'; }
and you would also probably need to alter open method to open write file of your choosing. In case you need it, here is nice tutorial about php streams.
If that does not work out for you, consider using TMemoryBuffer to serialize to string, and than you will find your way to put that into a file.
Upvotes: 1