urbanindo / yii2-thrift
使用 Yii2 的 Thrift 服务器应用程序
v2.1
2018-05-02 06:50 UTC
Requires
- apache/thrift: 0.10.0
- yiisoft/yii2: ~2.0.13
Requires (Dev)
- apache/thrift: 0.10.0
- phpunit/dbunit: >=1.2
- phpunit/php-code-coverage: 2.2.4
- phpunit/phpunit: 4.6.*
- squizlabs/php_codesniffer: 2.*
- yiisoft/yii2: ~2.0@dev
This package is auto-updated.
Last update: 2024-09-27 13:23:20 UTC
README
Yii2 的 Thrift 扩展
安装
安装此扩展的首选方式是通过 Composer。
运行以下命令之一:
php composer.phar require --prefer-dist urbanindo/yii2-thrift "*"
或添加
"urbanindo/yii2-thrift": "*"
最低要求
- Thrift 版本 0.10.0。要安装 Thrift,请访问 http://thrift.apache.org/download
- Yii 2.0.0
使用方法
将 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'; } }