gclove / thrift-laravel
use Thrift in Laravel 5.6, forked from Angejia/thrift-laravel
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 7
pkg:composer/gclove/thrift-laravel
Requires
- php: ^7.1.3
- illuminate/http: ~5.6
- illuminate/support: ~5.6
- symfony/http-foundation: 4.0.*
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^6.4
README
use Thrift in Laravel
How to use
Server side
-
composer require Gclove/thrift-laravel -
add provider to
app.providers:\Gclove\Thrift\ThriftServiceProvider::class -
setting
thrift.providersin fileconfig/thrift.php:// first is service name, defined in thrift file // second in Service implement reference, e.g. // class ImageServcie implement \Gclove\ImageServiceIf ['Gclove.ImageService', \Gclove\ImageService::class], -
add Middleware
\Gclove\Thrift\Middleware\ThriftServerMiddleware::classtoapp\Http\Kernelin default, the request to
/rpcwill be process by Middleware, if you want to change this, please extendThriftServerMiddlewareand overwriteprocessmethod
Client side
composer require Gclove/thrift-laravel- add provider in
app.providers:\Gclove\Thrift\ThriftServiceProvider::class - setting
thrift.dependsin fileconfig/thrift.php:// key is url // value is array of service name "http://localhost/rpc" => [ 'Gclove.ImageService', ] - usage:
/** @var \Gclove\Thrift\Contracts\ThriftClient $thriftClient */ $thriftClient = app(\Gclove\Thrift\Contracts\ThriftClient::class); /** @var \Gclove\ImageServiceIf $imageService */ $imageService = $thriftClient->with('Gclove.ImageService'); $result = $imageService->foo();
TODO
- Unittest