amrelnaggar / thrift
Apache Thrift package for Laravel 5
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: ^7.1.3
- apache/thrift: ^0.11.0
Requires (Dev)
- laravel/framework: ^5.6
- orchestra/testbench: ~3.0
This package is not auto-updated.
Last update: 2019-12-08 08:13:48 UTC
README
Requirements
This package is tested with the following but might work with other versions as well:
- PHP 7.1
- Apache Thrift 0.11.0
- Laravel 5.6
Installation
Laravel Thrift requires PHP 7.1 or 7.2. This version supports Laravel 5.5 or 5.6 only.
To get the latest version, simply require the project using Composer.
$ composer require amrelnaggar/thrift
Once installed, if you are not using automatic package discovery, then you need to register the AmrElNaggar\Thrift\ThriftServiceProvider
service provider in your config/app.php
.
You can also optionally alias our facade:
'Thrift' => AmrElNaggar\Thrift\ThriftFacade::class,
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="AmrElNaggar\Thrift\ThriftServiceProvider"
and then update config/thrift.php
to fit your needs.
'services' => [ /** * The service name * * `php artisan thrift:server name` */ 'example' => [ /** * Default host name */ 'host' => 'localhost', /** * Default port number */ 'port' => 8080, /** * The class that implements the interface defined in the thrift file. * * Required */ 'service' => '', /** * The generated class after calling `php artisan thrift:compile example.thrift --namespace=App\Example` * e.g. (App\Example\ExampleProcessor) * * Required in server mode */ 'processor' => '', /** * The generated class after calling `php artisan thrift:compile example.thrift --namespace=App\Example` * e.g. (App\Example\ExampleClient) * * Required in client mode */ 'client' => '', ], ],
Usage
1- Compile .thrift file:
php artisan thrift:compile {filename} {namespace}
php artisan thrift:compile example.thrift "App\\\Thrift\\\Example"
Note: Thrift generated file should not be committed to version control systems,
don't forget to add app/Thrift/Example
or wherever the generated files are to
your .gitignore
file.
2- Start Thrift server:
php artisan thrift:server {service} {--host=} {--port}
php artisan thrift:server example --host=localhost --port=8080
3- Test the running thrift server:
php artisan thrift:client {service} {method} {--arg=*} {--host=} {--port}
php artisan thrift:client calculator add --arg=5 --arg=3
4- Use Thrift
Facade:
$service = Thrift::service('calculator'); $result = $service->add(5, 3); Thrift::shutdown();
Further Information
There are other classes in this package that are not documented here. This is because they are not intended for public use and are used internally by this package.
Security
If you discover a security vulnerability within this package, please send an e-mail to Amr El-Naggar at amrlnaggar@gmail.com. All security vulnerabilities will be promptly addressed.
License
Laravel Thrift is licensed under The MIT License (MIT).