use Thrift in Laravel 5.6, forked from Angejia/thrift-laravel
gclove/thrift-laravel is a Laravel package for use thrift in laravel 5.6, forked from angejia/thrift-laravel.
It currently has 0 GitHub stars and 10 downloads on Packagist (latest version 1.0.0).
Install it with composer require gclove/thrift-laravel.
Discover more Laravel packages by gclove
or browse all Laravel packages to compare alternatives.
Last updated
use Thrift in Laravel
composer require Gclove/thrift-laravel
add provider to app.providers:
\Gclove\Thrift\ThriftServiceProvider::class
setting thrift.providers in file config/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::class to app\Http\Kernel
in default, the request to /rpc will be process by Middleware,
if you want to change this, please extend ThriftServerMiddleware and overwrite process method
composer require Gclove/thrift-laravelapp.providers:
\Gclove\Thrift\ThriftServiceProvider::class
thrift.depends in file config/thrift.php:
// key is url
// value is array of service name
"http://localhost/rpc" => [
'Gclove.ImageService',
]
/** @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();