douqianke7467 2014-09-29 06:36
浏览 58

如何在thrift中使用PHP和JAVA

I have installed thrift 0.8.0 in Ubuntu 12.04
I followed the all commands correctly with out any error but after installation it's working perfect

Now i want to use PHP by using thrift but in below code it only Shows YES for C++ and Python i need java and PHP but that two languages shows NO How can i use PHP and java in thrift, is there any library for java and php ?

thrift 0.8.0

Building code generators ..... :

Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : no
Building C# Library .......... : no
Building Python Library ...... : yes
Building Ruby Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Erlang Library ...... : no
Building Go Library .......... : no

Building TZlibTransport ...... : yes
Building TNonblockingServer .. : yes

Using Python ................. : /usr/bin/python
  • 写回答

2条回答 默认 最新

  • drxvjnx58751 2014-09-29 22:52
    关注

    First, download the source version of Thrift. I would strongly recommend using a newer version if possible. There are several ways to include the Thrift Java library (may have to change slightly for your Thrift version):

    If you are using maven, you can add the maven coordinates to your pom.xml:

    <dependency>
        <groupId>org.apache.thrift</groupId>
        <artifactId>libthrift</artifactId>
        <version>0.9.1</version>
    </dependency>
    

    Alternatively you can just download the JAR and add it your project:

    http://central.maven.org/maven2/org/apache/thrift/libthrift/0.9.1/libthrift-0.9.1.jar

    If you are using a version that has not been published to the central maven repositories, you can download the source tarball and navigate to the lib/java directory and build it with Apache Ant by typing:

    ant
    

    The library JAR will be in the lib/java/build directory. Optionally you can add the freshly built JAR to your local Maven repository:

    mvn install:install-file -DartifactId=libthrift -DgroupId=org.apache.thrift -Dvers
    

    For the PHP library, navigate to the lib/php/src directory and copy the PHP files into your project. You can then use the Thrift\ClassLoader\ThriftClassLoader class or the autoload.php script to include the Thrift PHP library. No build necessary unless you are trying to use the native PHP extension that implements the thrift protocol.

    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害