PHPackages                             edvakf/php-thrift-mapper - 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. edvakf/php-thrift-mapper

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

edvakf/php-thrift-mapper
========================

Convert a PHP array into an Apache Thrift struct type.

361PHP

Since Sep 10Pushed 10y ago1 watchersCompare

[ Source](https://github.com/edvakf/php-thrift-mapper)[ Packagist](https://packagist.org/packages/edvakf/php-thrift-mapper)[ RSS](/packages/edvakf-php-thrift-mapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-Thrift-Mapper
=================

[](#php-thrift-mapper)

Convert a PHP array into an Apache Thrift struct type.

[![Build Status](https://camo.githubusercontent.com/3fa8f8781cd54910a3200d96a073635cc9d67857fd8eb1ba0462264e66f46e5b/68747470733a2f2f7472617669732d63692e6f72672f656476616b662f7068702d7468726966742d6d61707065722e737667)](https://travis-ci.org/edvakf/php-thrift-mapper) [![Coverage Status](https://camo.githubusercontent.com/f523c8472c4f57a5a9a698c443873ea3530fcb22c5b22436fa75d09ba6a51ca0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f656476616b662f7068702d7468726966742d6d61707065722f62616467652e7376673f6272616e63683d636f766572616c6c7326736572766963653d676974687562)](https://coveralls.io/github/edvakf/php-thrift-mapper?branch=coveralls)

What is this?
-------------

[](#what-is-this)

A Thrift struct;

```
struct Bonk
{
  1: string message,
  2: i32 type
}

```

generates a PHP source like the following.

```
class Bonk {
  static $_TSPEC;

  /**
   * @var string
   */
  public $message = null;
  /**
   * @var int
   */
  public $type = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'message',
          'type' => TType::STRING,
          ),
        2 => array(
          'var' => 'type',
          'type' => TType::I32,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['message'])) {
        $this->message = $vals['message'];
      }
      if (isset($vals['type'])) {
        $this->type = $vals['type'];
      }
    }
  }

  public function getName() {
    return 'Bonk';
  }
```

Now, if I want to convert my PHP array to this class, there is no easy way.

Here comes the ThriftMapper
---------------------------

[](#here-comes-the-thriftmapper)

It populates the Thrift object with the PHP array.

```
$ary = [
  "message" => "Hello!",
  "type" => 123,
];

$bonk = ThriftMapper::map(new Bonk(), $ary);

var_dump($bonk);
```

This code outputs;

```
object(ThriftTest\Bonk)#19 (2) {
  ["message"]=>
  string(6) "Hello!"
  ["type"]=>
  int(123)
}

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/479092fc02a44ceb11ad32dad8bc8e7c712641a54a8c7b96cf1c164d02811c6f?d=identicon)[edvakf](/maintainers/edvakf)

---

Top Contributors

[![edvakf](https://avatars.githubusercontent.com/u/28143?v=4)](https://github.com/edvakf "edvakf (23 commits)")

### Embed Badge

![Health badge](/badges/edvakf-php-thrift-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/edvakf-php-thrift-mapper/health.svg)](https://phpackages.com/packages/edvakf-php-thrift-mapper)
```

PHPackages © 2026

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