@ -8,14 +8,16 @@ This tutorial provides a basic PHP programmer's introduction to working with gRP
It assumes a passing familiarity with [protocol buffers](https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto2 version of the protocol buffers language.
It assumes a passing familiarity with [protocol buffers](https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto2 version of the protocol buffers language.
Also note that currently you can only create clients in PHP for gRPC services - you can find out how to create gRPC servers in our other tutorials, e.g. [Node.js](https://github.com/grpc/grpc-common/tree/master/node/route_guide).
This isn't a comprehensive guide to using gRPC in PHP: more reference documentation is coming soon.
This isn't a comprehensive guide to using gRPC in PHP: more reference documentation is coming soon.
- [Why use gRPC?](#why-grpc)
- [Why use gRPC?](#why-grpc)
- [Example code and setup](#setup)
- [Example code and setup](#setup)
- [Try it out!](#try)
- [Defining the service](#proto)
- [Defining the service](#proto)
- [Generating client code](#protoc)
- [Generating client code](#protoc)
- [Creating the client](#client)
- [Creating the client](#client)
- [Try it out!](#try)
<aname="why-grpc"></a>
<aname="why-grpc"></a>
@ -41,6 +43,25 @@ Our example is a simple route mapping application that lets clients get informat
You also should have the relevant tools installed to generate the client interface code (and a server in another language, for testing). You can obtain the latter by following [these setup instructions](https://github.com/grpc/homebrew-grpc).
You also should have the relevant tools installed to generate the client interface code (and a server in another language, for testing). You can obtain the latter by following [these setup instructions](https://github.com/grpc/homebrew-grpc).
<aname="try"></a>
## Try it out!
To try the sample app, we need a gRPC server running locally. Let's compile and run, for example, the Node.js server in this repository:
The next sections guide you step-by-step through how this proto service is defined, how to generate a client library from it, and how to create a client stub that uses that library.
The next sections guide you step-by-step through how this proto service is defined, how to generate a client library from it, and how to create a client stub that uses that library.
@ -239,21 +260,3 @@ To read messages from the server:
```
```
Each side will always get the other's messages in the order they were written, both the client and server can read and write in any order — the streams operate completely independently.
Each side will always get the other's messages in the order they were written, both the client and server can read and write in any order — the streams operate completely independently.
<aname="try"></a>
## Try it out!
To try the sample app, we need a gRPC server running locally. Let's compile and run, for example, the Node.js server in this repository: