Rowan
Rowan

Reputation: 2595

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?

Upvotes: 1

Views: 1507

Answers (2)

ducin
ducin

Reputation: 26437

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).

Upvotes: 1

Rowan
Rowan

Reputation: 2595

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.

Upvotes: 3

Related Questions