PHP code generator for Twirp
Work in progress! First estimated preview: end of April
Download the latest release from the Releases page
and put it into your $PATH
prefix (or any location, but that requires some configuration, see later).
This is a protoc, so you will have to install that as well.
Alternatively you can manually download and build the project. For that, you are going to need dep.
$ go get github.com/twirphp/protoc-gen-twirp_php
$ cd $GOROOT/src/github.com/twirphp/protoc-gen-twirp_php
$ dep ensure
$ go install
Use it like any protoc plugin to generate both server and client code:
$ protoc -I example/ --php_out . --twirp_php . service.proto
If you downloaded the generator outside of your $PATH
prefix, you need to manually pass the location to the compiler:
$ protoc -I example/ --plugin=protoc-gen-twirp_php=path/to/protoc-gen-twirp_php --php_out . --twirp_php . service.proto
In order to use the server you have to install some dependencies in your PHP project via Composer:
$ composer require twirp/twirp
You need to choose a PSR-7 implementation along with it's factory:
$ composer require guzzlehttp/psr7 php-http/message
The code generator creates a service interface which you need to implement.
See the example directory for the implementation details.
In order to use the client you have to install some dependencies in your PHP project via Composer:
$ composer require twirp/twirp
You need to choose a PSR-7 implementation along with it's factory and an HTTPlug compatible client:
$ composer require guzzlehttp/psr7 php-http/message php-http/guzzle6-adapter
See the example directory for the implementation details.
The MIT License (MIT). Please see License File for more information.