angejia / thrift-laravel
use Thrift in Laravel
Installs: 1 786
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 7
Open Issues: 2
Requires
- php: >=7.0.0
- angejia/thrift: ^0.9.3.4
- illuminate/http: 5.1.*|5.2.*
- illuminate/support: 5.1.*|5.2.*
- symfony/http-foundation: 2.7.*|2.8.*|3.0.*
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
README
use Thrift in Laravel
How to use
Server side
-
composer require angejia/thrift-laravel
-
add provider to
app.providers
:\Angejia\Thrift\ThriftServiceProvider::class
-
setting
thrift.providers
in fileconfig/thrift.php
:// 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],
-
add Middleware
\Angejia\Thrift\Middleware\ThriftServerMiddleware::class
toapp\Http\Kernel
in default, the request to
/rpc
will be process by Middleware, if you want to change this, please extendThriftServerMiddleware
and overwriteprocess
method
Client side
composer require angejia/thrift-laravel
- add provider in
app.providers
:\Angejia\Thrift\ThriftServiceProvider::class
- setting
thrift.depends
in fileconfig/thrift.php
:// key is url // value is array of service name "http://localhost/rpc" => [ 'Angejia.ImageService', ]
- usage:
/** @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();
TODO
- Unittest