The Hortonworks Community Connection is now live. A completely rebuilt Q&A forum, Knowledge Base, Code Hub and more, backed by the experts in the industry.

You will be redirected here in 10 seconds. If your are not redirected, click here to visit the new site.

The legacy Hortonworks Forum is now closed. You can view a read-only version of the former site by clicking here. The site will be taken offline on January 31,2016

HBase Forum

Hbase + Thrift + php

  • #19165
    petri koski

    Hello, I am trying to use HBase using PHP. I know thrift and I got it running in my cluster (I just executed hbase thrift -threadpool start) However, where can I find files (.php files listed below .. ) needed in my webpage:

    $GLOBALS[‘THRIFT_ROOT’] = ‘/opt/thrift/lib/php/lib/Thrift’;

    require_once( $GLOBALS[‘THRIFT_ROOT’].’/Thrift.php’ );
    require_once( $GLOBALS[‘THRIFT_ROOT’].’/Transport/TSocket.php’ );
    require_once( $GLOBALS[‘THRIFT_ROOT’].’/Transport/TBufferedTransport.php’ );
    require_once( $GLOBALS[‘THRIFT_ROOT’].’/Protocol/TBinaryProtocol.php’ );

    # According to the thrift documentation, compiled PHP thrift libraries should
    # reside under the THRIFT_ROOT/packages directory. If these compiled libraries
    # are not present in this directory, move them there from gen-php/.
    require_once( $GLOBALS[‘THRIFT_ROOT’].’/packages/Hbase/Hbase.php’ );

    Maybe I got something wrong but little guidance would be helpful ..

    Petri Kosk

  • Author
  • #19172

    Hi Petri ,
    How is your day so far? To obtain the thrift interfaces you need to compile it using the the Thrift compiler Which can be used with Hbase API to obtain these files. Here is an example of Thrift & PHP& Hbase.
    thrift –gen php [hbase-root]/src/java/org/apache/hadoop/hbase/thrift/Hbase.thrift
    To download the thrift compiler go to this link.
    The compiler will generate the PHP interfaces with the thrift lib you are ready to go and package it. Please validate that the thrift server is started first before trying to use the thrift server interfaces.


    petri koski

    Hello abdelrahman !

    Thanks for your reply! You gave me a link to Download Thrift -compiler. So HDP is not that complete it would contain it ?
    I can see Thrift server when I execute “hbase” -command and I am able to start it. Still Compiler is after all missing ?


    xiaobo gu

    Hi Abdelrhaman,

    My Hbase was installed by Ambari, but I found the source code of Hbase including Hbase.thrift was not installed, so I use the sources downloaded form Apache web site. But I also found the thrift -gen php …. command only outputs THBaseService.php Types.php, which lacks a lot of files mentioned by many Thrift + Hbase integration examples. Do I miss anything?

The forum ‘HBase’ is closed to new topics and replies.

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.