zhongjq / thrift-laravel
在Laravel中使用Thrift
0.3.0
2018-08-04 07:05 UTC
Requires
- php: >=7.0.0
- angejia/thrift: ^0.9.3.4
- illuminate/http: >=5.1
- illuminate/support: >=5.1
- symfony/http-foundation: >=2.7
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^6.4
README
在Laravel中使用Thrift
如何使用
服务器端
-
composer require angejia/thrift-laravel -
在
app.providers中添加provider\Angejia\Thrift\ThriftServiceProvider::class -
在文件
config/thrift.php中设置thrift.providers// first is service name, defined in thrift file // second in Service implement reference, e.g. // class ImageServcie implement \Angejia\ImageServiceIf ['Angejia.ImageService', \Angejia\ImageService::class], -
将Middleware
\Angejia\Thrift\Middleware\ThriftServerMiddleware::class添加到app\Http\Kernel默认情况下,对
/rpc的请求将由Middleware处理,如果您想更改此行为,请扩展ThriftServerMiddleware并重写process方法
客户端
composer require angejia/thrift-laravel- 在
app.providers中添加provider\Angejia\Thrift\ThriftServiceProvider::class - 在文件
config/thrift.php中设置thrift.depends// key is url // value is array of service name "https:///rpc" => [ 'Angejia.ImageService', ] - 用法
/** @var \Angejia\Thrift\Contracts\ThriftClient $thriftClient */ $thriftClient = app(\Angejia\Thrift\Contracts\ThriftClient::class); /** @var \Angejia\ImageServiceIf $imageService */ $imageService = $thriftClient->with('Angejia.ImageService'); $result = $imageService->foo();
待办事项
- 单元测试