PHPackages                             bearsunday/thrift - 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. bearsunday/thrift

ActiveLibrary

bearsunday/thrift
=================

0.1.0(2y ago)12MITPHPPHP ^8.1

Since Mar 18Pushed 2y agoCompare

[ Source](https://github.com/bearsunday/BEAR.Thrift)[ Packagist](https://packagist.org/packages/bearsunday/thrift)[ RSS](/packages/bearsunday-thrift/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

BEAR.Sunday Thrift
==================

[](#bearsunday-thrift)

[![CI](https://github.com/bearsunday/BEAR.Thrift/actions/workflows/main.yml/badge.svg)](https://github.com/bearsunday/BEAR.Thrift/actions/workflows/main.yml)

A package that allows high-speed access to BEAR.Sunday resources from multiple languages using [Thrift](https://thrift.apache.org/) and [Swoole](https://www.php.net/manual/en/book.swoole.php).

Features
--------

[](#features)

- BEAR.Sunday resources can be utilized across various languages and frameworks
- Seamless access to remote BEAR.Sunday apps from the local BEAR.Sunday app
- Access resources regardless of language (currently supports PHP, Go, Python, Ruby and BEAR.Sunday)
- Fast access with Thrift/Swoole, compared to HTTP
- Can call resources from older versions of BEAR.Sunday apps
- Operates independently of an HTTP server

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

[](#installation)

```
composer require bearsunday/thrift

```

Usage
-----

[](#usage)

### Server-side (PHP:BEAR.Sunday)

[](#server-side-phpbearsunday)

bin/serve.php

```
(new ServerBootstrap)(new Config(
    appName: 'MyVendor\MyApp',
    hostname: '127.0.0.1',
    port: 9090,
    appDir: dirname(__DIR__) . '/path/to/app',
    context: 'prod-app',
    server: Engine::Swoole
))
```

Start Thrift server

```
> php bin/serve.php
[Sun Mar 17 19:39:20 2024] PHP 8.3.4 Thrift Server (powered by Swoole) started.
Listening on http://127.0.0.1:9090
Document root is /path/to/app
Application context is prod-hal-api-app
```

Client-side
-----------

[](#client-side)

### BEAR.Sunday

[](#bearsunday)

Import Thrift App in the module.

```
protected function configure(): void
{
    // Binding thirft app to a host called "sekai"
    $this->override(new ImportThriftAppModule([
        new ThriftApp('sekai', '127.0.0.1', '9090')
    ]));
}
```

Thrift apps available just like the 'self' app. See [more](/client/bear_client/main.php).

```
echo $resource->get('page://self/?name=Sekai');  // "greeting": "Konichiwa Sekai" from local app
echo $resource->get('page://sekai/?name=World'); // "greeting": "Hello World" from remote(127.0.0.1:9090) app
// echo $resource->get('/?name=World'); // "greeting": "Hello World" from remote(127.0.0.1:9090) app
```

### PHP

[](#php)

```
$method = 'get';
$uri = '/user?id=1';

$invoke = new ResourceInvoke($host, $port);
$response = $invoke($method, $uri);

assert($response instanceof ResourceResponse);
printf("Response Code: %s\n", $response->code);
printf("Response Headers: %s\n", json_encode($response->headers));
printf("Raw Response JsonValue: : %s\n", $response->jsonValue);
printf("Response View: %s\n", $response->view);
```

### Go

[](#go)

```
method := "get"
uri := "/user?id=1

response, err := ResourceInvoke(hostname, port, method, uri)

fmt.Println("Response Code:", response.Code)
fmt.Println("Response Headers:", response.Headers)
fmt.Println("Raw Response JsonValue: ", response.JsonValue)
fmt.Println("Response View:", response.View)
```

### Python

[](#python)

```
method = "get"
uri = "/user?id=1"

response = ResourceInvoke(hostname, port, method, uri)

print("Response Code:", response.code)
print("Response Headers:", response.headers)
print("Raw Response JsonValue:", response.jsonValue)
print("Response View:", response.view)
```

### Ruby

[](#ruby)

```
method = "get"
uri = "/user?id=1"

resource_invoke = ResourceInvoke.new(hostname, port)
response = resource_invoke.call(method, uri)

puts "Response Code: #{response.code}"
puts "Response Headers: #{response.headers}"
puts "Raw Response JsonValue: #{response.jsonValue}"
puts "Response View: #{response.view}"
```

Note: The URI can be a schema as well as a path. Instead of `/user?id=1`, you can specify `page://self/user?id=1` to access both app and page resources.

As you can see, it's easy to access BEAR.Sunday resources from other languages. **Resources become assets that transcend applications** and can be accessed quickly.

Demo
----

[](#demo)

Build go &amp; python and start the thrift server.

```
composer build:all
composer serve

```

Run the go and pythonclient with another terminal.

```
composer run:go
composer run:py
composer run:php

```

Note: Swoole, Thrift, go and python must be installed to run the above scripts. Straight forward if you're installing with brew.

```
brew install thrift
brew install go
brew install python3

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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 ~7 days

Total

2

Last Release

776d ago

Major Versions

0.1.0 → 1.x-dev2024-03-25

### Community

Maintainers

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

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (58 commits)")

---

Tags

swoolethrift

### Embed Badge

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

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

###  Alternatives

[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.1M29](/packages/yoast-yoastcs)[bear/package

BEAR.Sunday application framework package

30527.9k23](/packages/bear-package)

PHPackages © 2026

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