blob: cb9b48aee3a5e7749b27312dac56966dfacdf145 [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
murgatroid99975a07b2015-02-02 14:10:42 -080012Install `php5` and `php5-dev`.
mlumishb892a272014-12-09 16:28:23 -080013
Stanley Cheung3fa51a32015-06-09 16:16:42 -070014To run the tests, additionally install `phpunit`.
mlumishb892a272014-12-09 16:28:23 -080015
murgatroid99975a07b2015-02-02 14:10:42 -080016Alternatively, build and install PHP 5.5 or later from source with standard
17configuration options.
18
Stanley Cheung3fa51a32015-06-09 16:16:42 -070019## Build from Homebrew
mlumishb892a272014-12-09 16:28:23 -080020
Stanley Cheung3fa51a32015-06-09 16:16:42 -070021On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][]. Run the following command to
22install gRPC.
23
24```sh
25$ curl -fsSL https://goo.gl/getgrpc | bash -s php
mlumishb892a272014-12-09 16:28:23 -080026```
27
Stanley Cheung3fa51a32015-06-09 16:16:42 -070028This will download and run the [gRPC install script][] and compile the gRPC PHP extension.
mlumishb892a272014-12-09 16:28:23 -080029
Stanley Cheung3fa51a32015-06-09 16:16:42 -070030## Build from Source
mlumishb892a272014-12-09 16:28:23 -080031
Stanley Cheung3fa51a32015-06-09 16:16:42 -070032Clone this repository
mlumishb892a272014-12-09 16:28:23 -080033
Stanley Cheung3fa51a32015-06-09 16:16:42 -070034```
35$ git clone https://github.com/grpc/grpc.git
36```
mlumishb892a272014-12-09 16:28:23 -080037
Stanley Cheung3fa51a32015-06-09 16:16:42 -070038Build and install the Protocol Buffers compiler (protoc)
39
40```
41$ cd grpc
42$ git pull --recurse-submodules && git submodule update --init --recursive
43$ cd third_party/protobuf
44$ ./autogen.sh
45$ ./configure
46$ make
47$ make check
48$ sudo make install
49```
50
51Build and install the gRPC C core
52
53```sh
54$ cd grpc
55$ make
56$ sudo make install
57```
58
59Build the gRPC PHP extension
60
61```sh
62$ cd grpc/src/php/ext/grpc
63$ phpize
64$ ./configure
65$ make
66$ sudo make install
67```
68
69In your php.ini file, add the line `extension=grpc.so` to load the extension
70at PHP startup.
71
72Install Composer
73
74```sh
75$ cd grpc/src/php
76$ curl -sS https://getcomposer.org/installer | php
77$ php composer.phar install
78```
79
80## Unit Tests
81
82Run unit tests
83
84```sh
85$ cd grpc/src/php
86$ ./bin/run_tests.sh
87```
88
89## Generated Code Tests
90
91Install `protoc-gen-php`
92
93```sh
94$ cd grpc/src/php/vendor/datto/protobuf-php
95$ gem install rake ronn
96$ rake pear:package version=1.0
97$ sudo pear install Protobuf-1.0.tgz
98```
99
100Generate client stub code
101
102```sh
103$ cd grpc/src/php
104$ ./bin/generate_proto_php.sh
105```
106
107Run a local server serving the math services
108
109 - Please see [Node][] on how to run an example server
110
111```sh
112$ cd grpc/src/node
113$ npm install
114$ nodejs examples/math_server.js
115```
116
117Run the generated code tests
118
119```sh
120$ cd grpc/src/php
121$ ./bin/run_gen_code_test.sh
122```
123
124[homebrew]:http://brew.sh
125[linuxbrew]:https://github.com/Homebrew/linuxbrew#installation
126[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
127[Node]:https://github.com/grpc/grpc/tree/master/src/node/examples
128