After a year of development with Thrift on Java, C++, and Cocoa, we
recently tried to prepare some PHP sample code for an upcoming public
API release. I'm a bit confused about the (inconsistent?) use of
directories in the PHP generated code.
I have two simple Thrift IDL files: Body.thrift (the main project) and
Organs.thrift (a referenced child module) ...
// Body.thrift
include "Organs.thrift"
php_namespace com_evernote_body
namespace java com.evernote.body
struct Chest { 1: required Organs.Heart heart }
service Body { void operate(1: Chest chest) }
// Organs.thrift
php_namespace com_evernote_organs
namespace java com.evernote.organs
struct Heart { 1: required i32 pulse }
Using the trunk IDL compiler, I can generate Java and PHP sources like this:
thrift -r --gen java:beans -php Body.thrift
On the Java side, this will produce a nice directory structure based on
the Java namespace declarations, and the generated Java code will go
into those directories.
The generated PHP code just goes into a flat "gen-php" directory with no
subdirectories:
gen-php/Body.php
gen-php/Body_types.php
gen-php/Organs_types.php
The flat file structure could be ok, since the file names are
unambiguous, but the generated code seems to assume a more complicated
directory structure:
$ grep packages gen-php/*.php
gen-php/Body.php:include_once
$GLOBALS['THRIFT_ROOT'].'/packages/Body/Body_types.php';
gen-php/Body_types.php:include_once
$GLOBALS['THRIFT_ROOT'].'/packages/Organs/Organs_types.php';
It seems like the generated files go into a flat directory, but then
their internal include directives assume that the files are maintained
in per-IDL subdirectories. This means that the generated code can't be
used out of the box without moving some stuff around (as far as I can tell).
I'd be happy to submit a compiler patch that would resolve this by
either producing the expected subdirectory structure during generation,
or else excluding the subdirectories on the include directives.
However, I'm a bit concerned that this would break other folks who are
actually using PHP intensively today.
Could anyone shed any light on this?
Thanks