Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: third_party/grpc/src/php/README.md

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
2 #Overview
3
4 This directory contains source code for PHP implementation of gRPC layered on sh ared C library.
5
6 #Status
7
8 Beta
9
10 ## Environment
11
12 Prerequisite: `php` >=5.5, `phpize`, `pecl`, `phpunit`
13
14 **Linux (Debian):**
15
16 ```sh
17 $ sudo apt-get install php5 php5-dev php-pear
18 ```
19
20 **Linux (CentOS):**
21
22 ```sh
23 $ yum install php55w
24 $ yum --enablerepo=remi,remi-php55 install php-devel php-pear
25 ```
26
27 **Mac OS X:**
28
29 ```sh
30 $ curl -O http://pear.php.net/go-pear.phar
31 $ sudo php -d detect_unicode=0 go-pear.phar
32 ```
33
34 **PHPUnit:**
35 ```sh
36 $ wget https://phar.phpunit.de/phpunit-old.phar
37 $ chmod +x phpunit-old.phar
38 $ sudo mv phpunit-old.phar /usr/bin/phpunit
39 ```
40
41 ## Quick Install
42
43 Install the gRPC PHP extension
44
45 ```sh
46 sudo pecl install grpc-beta
47 ```
48
49 This will compile and install the gRPC PHP extension into the standard PHP exten sion directory. You should be able to run the [unit tests](#unit-tests), with th e PHP extension installed.
50
51 To run tests with generated stub code from `.proto` files, you will also need th e `composer`, `protoc` and `protoc-gen-php` binaries. You can find out how to ge t these [below](#generated-code-tests).
52
53 ## Build from Source
54
55
56 ### gRPC C core library
57
58 Clone this repository
59
60 ```sh
61 $ git clone https://github.com/grpc/grpc.git
62 ```
63
64 Build and install the gRPC C core library
65
66 ```sh
67 $ cd grpc
68 $ git pull --recurse-submodules && git submodule update --init --recursive
69 $ make
70 $ sudo make install
71 ```
72
73 ### gRPC PHP extension
74
75 Install the gRPC PHP extension from PECL
76
77 ```sh
78 $ sudo pecl install grpc-beta
79 ```
80
81 Or, compile from source
82
83 ```sh
84 $ cd grpc/src/php/ext/grpc
85 $ phpize
86 $ ./configure
87 $ make
88 $ sudo make install
89 ```
90
91 ### Update php.ini
92
93 Add this line to your `php.ini` file, e.g. `/etc/php5/cli/php.ini`
94
95 ```sh
96 extension=grpc.so
97 ```
98
99 ## Unit Tests
100
101 You will need the source code to run tests
102
103 ```sh
104 $ git clone https://github.com/grpc/grpc.git
105 $ cd grpc
106 $ git pull --recurse-submodules && git submodule update --init --recursive
107 ```
108
109 Run unit tests
110
111 ```sh
112 $ cd grpc/src/php
113 $ ./bin/run_tests.sh
114 ```
115
116 ## Generated Code Tests
117
118 This section specifies the prerequisites for running the generated code tests, a s well as how to run the tests themselves.
119
120 ### Composer
121
122 If you don't have it already, install `composer` to pull in some runtime depende ncies based on the `composer.json` file.
123
124 ```sh
125 $ curl -sS https://getcomposer.org/installer | php
126 $ sudo mv composer.phar /usr/local/bin/composer
127
128 $ cd grpc/src/php
129 $ composer install
130 ```
131
132 ### Protobuf compiler
133
134 Again if you don't have it already, you need to install the protobuf compiler `p rotoc`, version 3.0.0+.
135
136 If you compiled the gRPC C core library from source above, the `protoc` binary s hould have been installed as well. If it hasn't been installed, you can run the following commands to install it.
137
138 ```sh
139 $ cd grpc/third_party/protobuf
140 $ sudo make install # 'make' should have been run by core grpc
141 ```
142
143 Alternatively, you can download `protoc` binaries from [the protocol buffers Git hub repository](https://github.com/google/protobuf/releases).
144
145
146 ### PHP protobuf compiler
147
148 You need to install `protoc-gen-php` to generate stub class `.php` files from se rvice definition `.proto` files.
149
150 ```sh
151 $ cd grpc/src/php/vendor/datto/protobuf-php # if you had run `composer install` in the previous step
152
153 OR
154
155 $ git clone https://github.com/stanley-cheung/Protobuf-PHP # clone from github r epo
156
157 $ gem install rake ronn
158 $ rake pear:package version=1.0
159 $ sudo pear install Protobuf-1.0.tgz
160 ```
161
162 ### Client Stub
163
164 Generate client stub classes from `.proto` files
165
166 ```sh
167 $ cd grpc/src/php
168 $ ./bin/generate_proto_php.sh
169 ```
170
171 ### Run test server
172
173 Run a local server serving the math services. Please see [Node][] for how to run an example server.
174
175 ```sh
176 $ cd grpc
177 $ npm install
178 $ nodejs src/node/test/math/math_server.js
179 ```
180
181 ### Run test client
182
183 Run the generated code tests
184
185 ```sh
186 $ cd grpc/src/php
187 $ ./bin/run_gen_code_test.sh
188 ```
189
190 ## Use the gRPC PHP extension with Apache
191
192 Install `apache2`, in addition to `php5` above
193
194 ```sh
195 $ sudo apt-get install apache2
196 ```
197
198 Add this line to your `php.ini` file, e.g. `/etc/php5/apache2/php.ini`
199
200 ```sh
201 extension=grpc.so
202 ```
203
204 Restart apache
205
206 ```sh
207 $ sudo service apache2 restart
208 ```
209
210 Make sure the Node math server is still running, as above.
211
212 ```sh
213 $ cd grpc
214 $ npm install
215 $ nodejs src/node/test/math/math_server.js
216 ```
217
218 Make sure you have run `composer install` to generate the `vendor/autoload.php` file
219
220 ```sh
221 $ cd grpc/src/php
222 $ composer install
223 ```
224
225 Make sure you have generated the client stub `math.php`
226
227 ```sh
228 $ ./bin/generate_proto_php.sh
229 ```
230
231 Copy the `math_client.php` file into your Apache document root, e.g.
232
233 ```sh
234 $ cp tests/generated_code/math_client.php /var/www/html
235 ```
236
237 You may have to fix the first two lines to point the includes to your installati on:
238
239 ```php
240 include 'vendor/autoload.php';
241 include 'tests/generated_code/math.php';
242 ```
243
244 Connect to `localhost/math_client.php` in your browser, or run this from command line:
245
246 ```sh
247 $ curl localhost/math_client.php
248 ```
249
250 ## Use the gRPC PHP extension with Nginx/PHP-FPM
251
252 Install `nginx` and `php5-fpm`, in addition to `php5` above
253
254 ```sh
255 $ sudo apt-get install nginx php5-fpm
256 ```
257
258 Add this line to your `php.ini` file, e.g. `/etc/php5/fpm/php.ini`
259
260 ```sh
261 extension=grpc.so
262 ```
263
264 Uncomment the following lines in your `/etc/nginx/sites-available/default` file:
265
266 ```
267 location ~ \.php$ {
268 include snippets/fastcgi-php.conf;
269 fastcgi_pass unix:/var/run/php5-fpm.sock;
270 }
271 ```
272
273 Restart nginx and php-fpm
274
275 ```sh
276 $ sudo service nginx restart
277 $ sudo service php5-fpm restart
278 ```
279
280 Make sure the Node math server is still running, as above.
281
282 ```sh
283 $ cd grpc
284 $ npm install
285 $ nodejs src/node/test/math/math_server.js
286 ```
287
288 Make sure you have run `composer install` to generate the `vendor/autoload.php` file
289
290 ```sh
291 $ cd grpc/src/php
292 $ composer install
293 ```
294
295 Make sure you have generated the client stub `math.php`
296
297 ```sh
298 $ ./bin/generate_proto_php.sh
299 ```
300
301 Copy the `math_client.php` file into your Nginx document root, e.g.
302
303 ```sh
304 $ cp tests/generated_code/math_client.php /var/www/html
305 ```
306
307 You may have to fix the first two lines to point the includes to your installati on:
308
309 ```php
310 include 'vendor/autoload.php';
311 include 'tests/generated_code/math.php';
312 ```
313
314 Connect to `localhost/math_client.php` in your browser, or run this from command line:
315
316 ```sh
317 $ curl localhost/math_client.php
318 ```
319
320 [Node]:https://github.com/grpc/grpc/tree/master/src/node/examples
OLDNEW
« no previous file with comments | « third_party/grpc/src/php/.gitignore ('k') | third_party/grpc/src/php/bin/determine_extension_dir.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698