PHPackages                             tomasz-rup/sf-thrift-plugin - 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. tomasz-rup/sf-thrift-plugin

ActiveSymfony1-plugin

tomasz-rup/sf-thrift-plugin
===========================

symfony 1.x Apache Thrift plugin

04PHP

Since Dec 31Pushed 7y ago1 watchersCompare

[ Source](https://github.com/tomi77/sfThriftPlugin)[ Packagist](https://packagist.org/packages/tomasz-rup/sf-thrift-plugin)[ RSS](/packages/tomasz-rup-sf-thrift-plugin/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

sfThrift plugin
===============

[](#sfthrift-plugin)

[![StyleCI](https://camo.githubusercontent.com/0c99aed9ee78a90ef5e0c446bd841412c0ceab7816b32567a926c99f274f39c4/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f34393539313238382f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/49591288)

A simple symfony 1.x [Apache Thrift](http://incubator.apache.org/thrift/) plugin. Base for other Thrift plugins.

Installation
------------

[](#installation)

- Install the plugin

    ```
    $ composer require tomasz-rup/sf-thrift-plugin
    ```

Configuration
-------------

[](#configuration)

- Configuration is in app.yml:

    ```
    all:
      thrift_plugin:
        default:
          connector:
            class: TSocket
            param:
              host: 127.0.0.1
              port: 9090
          transport:
            class: TBufferedTransport
          protocol:
            class: TBinaryProtocol
    ```

Connectors
----------

[](#connectors)

- **THttpClient**

    HTTP client

    *Params:*

    - **host *\[required\]*** The host to connect to
    - **port *\[optional, default: 80\]*** The port to connect on
    - **uri *\[optional, default: ''\]*** The URI to request
    - **scheme *\[optional, default: 'http'\]*** The scheme to use for the request, i.e. http, https
    - **timeout *\[optional, default: null\]*** Read timeout
- **TMemoryBuffer**

    A memory buffer is a tranpsort that simply reads from and writes to an in-memory string buffer. Anytime you call write on it, the data is simply placed into a buffer, and anytime you call read, data is read from that buffer.

    *Params:*

    - **buf *\[optional, default: ''\]*** Initial buffer value
- **TPhpStream**

    Php stream transport. Reads to and writes from the php standard streams php://input and php://output

    *Params:*

    - **mode *\[required\]***
- **TServerSocket**

    *Params:*

    - **host *\[optional, default: 'localhost'\]*** Host to listen on
    - **port *\[optional: default: 9090\]*** Port to listen on
- **TSocket**

    *Params:*

    - **host *\[optional, default: 'localhost'\]*** Remote hostname
    - **port *\[optional: default: 9090\]*** Remote port
    - **persist *\[optional, default: false\]*** Whether to use a persistent socket
    - **send\_timeout *\[optional, default: 100\]*** Send timeout in milliseconds
    - **recv\_timeout *\[optional, default: 750\]*** Recv timeout in milliseconds
- **TSocketPool**

    *Params:*

    - **hosts *\[optional, default: array('localhost')\]*** List of remote hostnames
    - **ports *\[optional default: array(9090)\]*** List of remote ports, or a single common port
    - **persist *\[optional, default: false\]*** Whether to use a persistent socket
    - **send\_timeout *\[optional, default: 100\]*** Send timeout in milliseconds
    - **recv\_timeout *\[optional, default: 750\]*** Recv timeout in milliseconds

Transports
----------

[](#transports)

- **TBufferedTransport**

    Buffered transport. Stores data to an internal buffer that it doesn't actually write out until flush is called. For reading, we do a greedy read and then serve data out of the internal buffer.

    *Params:*

    - **read\_buf\_size *\[optional, default: 512\]*** The receive buffer size
    - **write\_buf\_size *\[optional, default: 512\]*** The write buffer size
- **TFramedTransport**

    Framed transport. Writes and reads data in chunks that are stamped with their length.

    *Params:*

    - **read *\[optional, default: false\]*** Buffer for read data.
    - **write *\[optional, default: false\]*** Buffer for queued output data
- **TNullTransport**

    Transport that only accepts writes and ignores them. This is useful for measuring the serialized size of structures.

Protocols
---------

[](#protocols)

- **TBinaryProtocol**

    Binary protocol.

    *Params:*

    - **strict\_read *\[optional, default: false\]***
    - **strict\_write *\[optional, default: true\]***
- **TBinaryProtocolAccelerated**

    Accelerated binary protocol.

    *Params:*

    - **strict\_read *\[optional, default: false\]***
    - **strict\_write *\[optional, default: true\]***
- **TCompactProtocol**

    Compact protocol.

Use
---

[](#use)

- Generate files

    ```
    thrift --gen php example.thrift
    ```
- Copy those generated files to your project lib directory
- Remove `include ...` lines from generated files
- Create a client object:

    ```
    $service = new example_serviceClient(ThriftProtocolFactory::factory());
    ```

More Thrift services
--------------------

[](#more-thrift-services)

We can create many named configurations:

```
all:
  thrift_plugin:
    # First service configuration
    service1:
      connector:
        class: TSocket
        param:
          host: 127.0.0.1
          port: 9090
      transport:
        class: TBufferedTransport
      protocol:
        class: TBinaryProtocol
    # Second service configuration
    service2:
      connector:
        class: TSocket
        param:
          host: 192.168.1.1
          port: 9091
      transport:
        class: TFramedTransport
      protocol:
        class: TBinaryProtocolAccelerated
```

Now we can use it:

```
$service1 = new FirstClient(ThriftProtocolFactory::factory('service1'));
$service2 = new SecondClient(ThriftProtocolFactory::factory('service2'));
```

Example
-------

[](#example)

This is example from Thrift project site:

1. Create `UserStorage.thrift` file:

    ```
    struct UserProfile {
      1: i32 uid,
      2: string name,
      3: string blurb
    }
    service UserStorage {
      void store(1: UserProfile user),
      UserProfile retrieve(1: i32 uid)
    }

    ```
2. Generate UserStorage service files for PHP:

    ```
    thrift --gen php UserStorage.thrift
    ```
3. Move generated files to proper place (like lib/thrift folder)
4. Remove `include ...` lines from generated files
5. Use client:

    ```
    $service = new UserStorageClient(ThriftProtocolFactory::factory());
    $service->store($user);
    $user2 = $service->retrieve(1);
    ```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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/ba2f80ee975530bd087edb0490264d435755d5142b5c3a9b06715365a6b9d485?d=identicon)[tomasz.rup](/maintainers/tomasz.rup)

---

Top Contributors

[![tomi77](https://avatars.githubusercontent.com/u/490094?v=4)](https://github.com/tomi77 "tomi77 (11 commits)")

---

Tags

symfony1-pluginthrift

### Embed Badge

![Health badge](/badges/tomasz-rup-sf-thrift-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/tomasz-rup-sf-thrift-plugin/health.svg)](https://phpackages.com/packages/tomasz-rup-sf-thrift-plugin)
```

PHPackages © 2026

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