angejia/thrift-laravel

use Thrift in Laravel
1,788 11
Install
composer require angejia/thrift-laravel
Latest Version:0.2.13
PHP:>=7.0.0
License:MIT
Last Updated:Sep 19, 2016
Links: GitHub  ·  Packagist
Maintainer: angejia

thrift-laravel

use Thrift in Laravel

How to use

Server side

  1. composer require angejia/thrift-laravel

  2. add provider to app.providers:

    \Angejia\Thrift\ThriftServiceProvider::class
    
  3. 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 \Angejia\ImageServiceIf
    ['Angejia.ImageService', \Angejia\ImageService::class],
    
  4. add Middleware \Angejia\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

Client side

  1. composer require angejia/thrift-laravel
  2. add provider in app.providers:
    \Angejia\Thrift\ThriftServiceProvider::class
    
  3. setting thrift.depends in file config/thrift.php:
    // key is url
    // value is array of service name
    "http://localhost/rpc" => [
        'Angejia.ImageService',
    ]
    
  4. 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

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

418,291,778 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
0.2.13 >=7.0.0 5.1.*|5.2.* MIT
0.2.12 >=7.0.0 5.1.* MIT
0.2.11 >=7.0.0 5.1.* MIT
0.2.10 >=7.0.0 5.1.* MIT
0.2.9 >=7.0.0 5.1.* MIT