Jayant Kolhe | 300748e | 2015-02-19 11:30:40 -0800 | [diff] [blame] | 1 | |
| 2 | #Overview |
| 3 | |
| 4 | This directory contains source code for PHP implementation of gRPC layered on shared C library. |
| 5 | |
| 6 | #Status |
| 7 | |
Jayant Kolhe | 691dbcc | 2015-02-19 11:31:20 -0800 | [diff] [blame] | 8 | Pre-Alpha : This gRPC PHP implementation is work-in-progress and is not expected to work yet. |
Jayant Kolhe | 300748e | 2015-02-19 11:30:40 -0800 | [diff] [blame] | 9 | |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 10 | ## ENVIRONMENT |
| 11 | |
Stanley Cheung | cb14eab | 2015-06-16 17:33:34 -0700 | [diff] [blame^] | 12 | Prerequisite: PHP 5.5 or later, PHPUnit, pecl |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 13 | |
Stanley Cheung | cb14eab | 2015-06-16 17:33:34 -0700 | [diff] [blame^] | 14 | ```sh |
| 15 | sudo apt-get install php5 php5-dev phpunit php-pear |
| 16 | ``` |
murgatroid99 | 975a07b | 2015-02-02 14:10:42 -0800 | [diff] [blame] | 17 | |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 18 | ## Build from Homebrew |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 19 | |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 20 | On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][]. Run the following command to |
| 21 | install gRPC. |
| 22 | |
| 23 | ```sh |
| 24 | $ curl -fsSL https://goo.gl/getgrpc | bash -s php |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 25 | ``` |
| 26 | |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 27 | This will download and run the [gRPC install script][] and compile the gRPC PHP extension. |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 28 | |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 29 | ## Build from Source |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 30 | |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 31 | Clone this repository |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 32 | |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 33 | ``` |
| 34 | $ git clone https://github.com/grpc/grpc.git |
| 35 | ``` |
mlumish | b892a27 | 2014-12-09 16:28:23 -0800 | [diff] [blame] | 36 | |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 37 | Build 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 Cheung | cb14eab | 2015-06-16 17:33:34 -0700 | [diff] [blame^] | 50 | Build and install the gRPC C core libraries |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 51 | |
| 52 | ```sh |
| 53 | $ cd grpc |
| 54 | $ make |
| 55 | $ sudo make install |
| 56 | ``` |
| 57 | |
Stanley Cheung | cb14eab | 2015-06-16 17:33:34 -0700 | [diff] [blame^] | 58 | Install the gRPC PHP extension |
| 59 | |
| 60 | ```sh |
| 61 | $ sudo pecl install grpc |
| 62 | ``` |
| 63 | |
| 64 | OR |
Stanley Cheung | 3fa51a3 | 2015-06-09 16:16:42 -0700 | [diff] [blame] | 65 | |
| 66 | ```sh |
| 67 | $ cd grpc/src/php/ext/grpc |
| 68 | $ phpize |
| 69 | $ ./configure |
| 70 | $ make |
| 71 | $ sudo make install |
| 72 | ``` |
| 73 | |
| 74 | In your php.ini file, add the line `extension=grpc.so` to load the extension |
| 75 | at PHP startup. |
| 76 | |
| 77 | Install 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 | |
| 87 | Run unit tests |
| 88 | |
| 89 | ```sh |
| 90 | $ cd grpc/src/php |
| 91 | $ ./bin/run_tests.sh |
| 92 | ``` |
| 93 | |
| 94 | ## Generated Code Tests |
| 95 | |
| 96 | Install `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 | |
| 105 | Generate client stub code |
| 106 | |
| 107 | ```sh |
| 108 | $ cd grpc/src/php |
| 109 | $ ./bin/generate_proto_php.sh |
| 110 | ``` |
| 111 | |
| 112 | Run 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 | |
| 122 | Run 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 |