blob: 42ddb2d7317bc272235d0ca18b3b1fe41dd041d4 [file] [log] [blame] [view]
Jayant Kolhe300748e2015-02-19 11:30:40 -08001
2#Overview
3
4This directory contains source code for PHP implementation of gRPC layered on shared C library.
5
6#Status
7
Jayant Kolhe691dbcc2015-02-19 11:31:20 -08008Pre-Alpha : This gRPC PHP implementation is work-in-progress and is not expected to work yet.
Jayant Kolhe300748e2015-02-19 11:30:40 -08009
mlumishb892a272014-12-09 16:28:23 -080010## ENVIRONMENT
11
Stanley Cheungcb14eab2015-06-16 17:33:34 -070012Prerequisite: PHP 5.5 or later, PHPUnit, pecl
mlumishb892a272014-12-09 16:28:23 -080013
Stanley Cheungcb14eab2015-06-16 17:33:34 -070014```sh
15sudo apt-get install php5 php5-dev phpunit php-pear
16```
murgatroid99975a07b2015-02-02 14:10:42 -080017
Stanley Cheung3fa51a32015-06-09 16:16:42 -070018## Build from Homebrew
mlumishb892a272014-12-09 16:28:23 -080019
Stanley Cheung3fa51a32015-06-09 16:16:42 -070020On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][]. Run the following command to
21install gRPC.
22
23```sh
24$ curl -fsSL https://goo.gl/getgrpc | bash -s php
mlumishb892a272014-12-09 16:28:23 -080025```
26
Stanley Cheung3fa51a32015-06-09 16:16:42 -070027This will download and run the [gRPC install script][] and compile the gRPC PHP extension.
mlumishb892a272014-12-09 16:28:23 -080028
Stanley Cheung3fa51a32015-06-09 16:16:42 -070029## Build from Source
mlumishb892a272014-12-09 16:28:23 -080030
Stanley Cheung3fa51a32015-06-09 16:16:42 -070031Clone this repository
mlumishb892a272014-12-09 16:28:23 -080032
Stanley Cheung3fa51a32015-06-09 16:16:42 -070033```
34$ git clone https://github.com/grpc/grpc.git
35```
mlumishb892a272014-12-09 16:28:23 -080036
Stanley Cheung3fa51a32015-06-09 16:16:42 -070037Build and install the Protocol Buffers compiler (protoc)
38
39```
40$ cd grpc
41$ git pull --recurse-submodules && git submodule update --init --recursive
42$ cd third_party/protobuf
43$ ./autogen.sh
44$ ./configure
45$ make
46$ make check
47$ sudo make install
48```
49
Stanley Cheungcb14eab2015-06-16 17:33:34 -070050Build and install the gRPC C core libraries
Stanley Cheung3fa51a32015-06-09 16:16:42 -070051
52```sh
53$ cd grpc
54$ make
55$ sudo make install
56```
57
Stanley Cheungcb14eab2015-06-16 17:33:34 -070058Install the gRPC PHP extension
59
60```sh
61$ sudo pecl install grpc
62```
63
64OR
Stanley Cheung3fa51a32015-06-09 16:16:42 -070065
66```sh
67$ cd grpc/src/php/ext/grpc
68$ phpize
69$ ./configure
70$ make
71$ sudo make install
72```
73
74In your php.ini file, add the line `extension=grpc.so` to load the extension
75at PHP startup.
76
77Install Composer
78
79```sh
80$ cd grpc/src/php
81$ curl -sS https://getcomposer.org/installer | php
82$ php composer.phar install
83```
84
85## Unit Tests
86
87Run unit tests
88
89```sh
90$ cd grpc/src/php
91$ ./bin/run_tests.sh
92```
93
94## Generated Code Tests
95
96Install `protoc-gen-php`
97
98```sh
99$ cd grpc/src/php/vendor/datto/protobuf-php
100$ gem install rake ronn
101$ rake pear:package version=1.0
102$ sudo pear install Protobuf-1.0.tgz
103```
104
105Generate client stub code
106
107```sh
108$ cd grpc/src/php
109$ ./bin/generate_proto_php.sh
110```
111
112Run a local server serving the math services
113
114 - Please see [Node][] on how to run an example server
115
116```sh
117$ cd grpc/src/node
118$ npm install
119$ nodejs examples/math_server.js
120```
121
122Run the generated code tests
123
124```sh
125$ cd grpc/src/php
126$ ./bin/run_gen_code_test.sh
127```
128
129[homebrew]:http://brew.sh
130[linuxbrew]:https://github.com/Homebrew/linuxbrew#installation
131[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
132[Node]:https://github.com/grpc/grpc/tree/master/src/node/examples