Skip to content

twirphp/protoc-gen-twirp_php

Repository files navigation

PHP code generator for Twirp

Build Status Twirp Version Go Report Card GoDoc

Work in progress! First estimated preview: end of April

Installation

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

Usage

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

Server

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.

Client

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.

License

The MIT License (MIT). Please see License File for more information.