參考網上教程,使用$loader->registerDefinition('Sample', $GEN_DIR); 可是會報PHP Fatal error: Uncaught Error: Class 'Sample\formatDataClient' not found in /Users/work/local/gopath/src/rpc/phprpc-client.php:32。也就是類加載失敗啦。緣由應該是由於php-v0.12版本使用的PSR-4 記載規範。而且提示使用$thriftClassLoader->registerNamespace('namespace', '<path>')
而不是 u$thriftClassLoader->registerDefinition('namespace', '<path>')
.php
使用php的thrift,有兩點須要注意:spa
1.須要將thrift/lib/php/*中的內容複製到本身定義的thrift的庫目錄,如phplib中,而後將子目錄lib改爲Thrift,不然會報錯。由於是ClassLoader/ThriftClassLoader.php的152行地方的namespace是以Thrift\開頭的。code
2.上面提到的服務也要用$loader->registerNamespace('Sample', $dir)orm