urbanindo/yii2-thrift

使用 Yii2 的 Thrift 服务器应用程序

v2.1 2018-05-02 06:50 UTC

This package is auto-updated.

Last update: 2024-09-27 13:23:20 UTC


README

Yii2 的 Thrift 扩展

Latest Stable Version Total Downloads Latest Unstable Version Build Status

安装

安装此扩展的首选方式是通过 Composer

运行以下命令之一:

php composer.phar require --prefer-dist urbanindo/yii2-thrift "*"

或添加

"urbanindo/yii2-thrift": "*"

最低要求

使用方法

将 thrift 文件放入根目录下的某个目录(推荐使用 thrift 目录)。

使用以下命令生成 thrift 文件。

thrift --gen php:server,oop path/to/the/thrift/file

index.php 中,使用 UrbanIndo\Yii2\Thrift\Application 替代默认的 yii\web\Application

在组件配置中添加 thrift 配置。

return [
    'component' => [
        'thrift' => [
            'serviceMap' => [
                '' => 'service'
            ]
        ]
    ]
]

services 目录中创建一个服务,类似于 controllers 目录。此服务应实现生成的 Thrift 文件中的接口 UrbanIndo\Yii2\Thrift\Service 接口。

class HelloService implements \myservice\HelloServiceIf, \UrbanIndo\Yii2\Thrift\Service {

    public function getProcessorClass {
        return 'myservice\HelloServiceProcessor';
    }
}