PHPackages                             gtt/thrift-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gtt/thrift-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gtt/thrift-generator
====================

Generates .thrift files based on php classes signatures

0.3.0(11y ago)556MITPHPPHP &gt;=5.3.3CI failing

Since Nov 18Pushed 6y ago3 watchersCompare

[ Source](https://github.com/GlobalTradingTechnologies/ThriftGenerator)[ Packagist](https://packagist.org/packages/gtt/thrift-generator)[ RSS](/packages/gtt-thrift-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

ThriftGenerator
===============

[](#thriftgenerator)

Generates [apache thrift](http://thrift.apache.org/) definition files based on PHP classes signature.

[![Build Status](https://camo.githubusercontent.com/955884ee50769a086c858fb85434b31a74c1b1aef2aa1e2c4c070e78cda95a4c/68747470733a2f2f7472617669732d63692e6f72672f476c6f62616c54726164696e67546563686e6f6c6f676965732f54687269667447656e657261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/GlobalTradingTechnologies/ThriftGenerator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/90b8c7414987be43fb5ea637e2aaad47f81504bce9085d17a171796e833a1620/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f476c6f62616c54726164696e67546563686e6f6c6f676965732f54687269667447656e657261746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GlobalTradingTechnologies/ThriftGenerator/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/9c38bd488df200f567e6c17f388d12ff3fda761a15599343af7a45eb7c4a9424/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f476c6f62616c54726164696e67546563686e6f6c6f676965732f54687269667447656e657261746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GlobalTradingTechnologies/ThriftGenerator/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/696c4dc75df51f07fabf40b290b91d3783fa79c641a6f0e578d3a8bd3fbc14c1/68747470733a2f2f706f7365722e707567782e6f72672f6774742f7468726966742d67656e657261746f722f762f737461626c652e737667)](https://packagist.org/packages/gtt/thrift-generator)[![Latest Unstable Version](https://camo.githubusercontent.com/ba4ab80f25ef69f1df4e6ec586349e4f744aa4ca69fab5611ca6a24108419692/68747470733a2f2f706f7365722e707567782e6f72672f6774742f7468726966742d67656e657261746f722f762f756e737461626c652e737667)](https://packagist.org/packages/gtt/thrift-generator)[![License](https://camo.githubusercontent.com/a139dee01081d2d777580dcbc879003f818a604792eb7c84430d07937326285a/68747470733a2f2f706f7365722e707567782e6f72672f6774742f7468726966742d67656e657261746f722f6c6963656e73652e737667)](https://packagist.org/packages/gtt/thrift-generator)

What's the purpose?
===================

[](#whats-the-purpose)

The main apache thrift's concept is to make possible cross-language services development that can interact with each other. In order to product code that can be invoked remotely using thrift framework you need firstly provide all target classes definitions in special [thrift](http://thrift.apache.org/docs/idl) files and then generate service thrift code. But imagine you already have some server classes and you want to provide some RPC API for them using thrift. In this case manual filling of thrift files for those server classes seems to be annoying. ThriftGenerator uses class reflection and doc-blocks to introspect class signatures and generate corresponding thrift files automatically for you. This thrift files would be used then to generate thrift service stuff that can be used on server side with the help of original thrift compiler.

Requirements
============

[](#requirements)

ThriftGenerator works with PHP classes and requires PHP 5.3 or higher and provides thrift definition files can be used by thrift compiler 0.9.2 and higher.

Installation
============

[](#installation)

ThriftGenerator can be installed with composer quite easy:

```
composer require gtt/thrift-generator 0.1.0

```

You also can use ThriftGenerator as a standalone library:

```
git clone https://github.com/GlobalTradingTechnologies/ThriftGenerator && cd ThriftGenerator
composer install --prefer-dist

```

Usage
=====

[](#usage)

ThriftGenerator has handy OOP interface:

```
use Gtt\ThriftGenerator\Generator\ThriftGenerator;

$generator = new ThriftGenerator();
$generator
    // set classes that should be introspected in order to generate thrift definition files
    ->setClasses(
        array(
            new ReflectionClass("\Your\Class\Name"),
            new ReflectionClass("\Another\Class\Name")
        )
    )
    // set output dir
    ->setOutputDir("")
    // generate!
    ->generate();
```

See also [demos](demos) and [functional test cases](tests/Fixtures) for more details.

Restrictions
============

[](#restrictions)

Sinсe ThriftGenerator statically introspects PHP class signature only with use of Reflection functionality so it have no chance to detect and define in thrift IDL any classes that is used internally in your classes (in most cases that is not described in class doc-blocks as input params, return values or exceptions can be thrown).

Roadmap
=======

[](#roadmap)

It would be nice to have some features that are not implemented yet:

1. Support of relative complex type/exception names (not FQCN's) in doc blocks.
2. Thrift service inheritance support.
3. Comments in generated thrift files.
4. Custom doc-block's implementation to support some thrift-related options that can not be reflected from PHP method signatures or doc blocks (container types wide support, one-way calls, enum's and etc).
5. Thrift versioning support.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~19 days

Total

3

Last Release

4158d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aff38c7c201e49cb668c6f45e6577f009f9acc211fe41f3737368cdc5de2c5f0?d=identicon)[fduch](/maintainers/fduch)

![](https://www.gravatar.com/avatar/bb355559c0366ede2f505345c1063cec701c24f5c473cc6825a8b3b807970af9?d=identicon)[gtt](/maintainers/gtt)

---

Top Contributors

[![fduch](https://avatars.githubusercontent.com/u/1204137?v=4)](https://github.com/fduch "fduch (75 commits)")

---

Tags

phpgeneratorthrift

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gtt-thrift-generator/health.svg)

```
[![Health](https://phpackages.com/badges/gtt-thrift-generator/health.svg)](https://phpackages.com/packages/gtt-thrift-generator)
```

###  Alternatives

[genericmilk/docudoodle

Generate documentation for your Laravel application using OpenAI

15120.5k](/packages/genericmilk-docudoodle)[tomloprod/radiance

A deterministic mesh gradient avatar generator for PHP.

1393.7k](/packages/tomloprod-radiance)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
