简体   繁体   中英

Thrift 0.9 PHP server missing Processor

I'm writing an application that communicates by Thrift. I'm using Thrift 0.9.0 (installed via homebrew on OSX). I have a working Java server and client, but I'm struggling to write a PHP server, as the *Processor class isn't being generated.

The PHP documentation for Thrift is essentially absent , but I'm expecting the *Processor class to be generated because:

When I generate the PHP code from the tutorial.thrift file ( thrift -r --gen php:namespace tutorial.thrift ), however, the resulting Calculator.php doesn't contain a CalculatorProcessor class.

Am I missing something?

The process of writing this question prompted me to spot the answer!

I was generating php:namespace , but that was a hold-over from using Thrift 0.8.0. In fact, 'namespace' doesn't exist in 0.8 (presumably because namespaces are always added to generated PHP in 0.9). The output of thrift --help does list php:server , which "generates PHP server stubs". This means, apparently, generating the PHP *Processor class.

I've got a very similar application as you defined (Java Server with PHP Client).

I've got following thrift definitions file:

namespace java com.blogspot.symfonyworld.wealthylaughingduck.thrift.generated
namespace php SymfonyWorld.WealthyLaughingDuck

# definitions below

and I run the following commands to regenerate the thrift classes:

thrift -r --gen java -out src/main/java src/submodules/commons/thrift/service.thrift
thrift -r --gen php:oop,namespace,autoload -out src/main/php/packages src/submodules/commons/thrift/service.thrift

And it works like a charm :) Take a look at my github application - it works out of the box (you may watch Java log4j output as you click in the interface).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM