From cb14eab39569d43c1451a1287d7f73b3dfbc5817 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Tue, 16 Jun 2015 17:33:34 -0700 Subject: [PATCH] Add package.xml and necessary files for pecl extension --- src/php/README.md | 20 +++++---- src/php/bin/run_tests.sh | 30 ++++++++++--- src/php/ext/grpc/CREDITS | 3 ++ src/php/ext/grpc/LICENSE | 32 ++++++++++++++ src/php/ext/grpc/README.md | 72 +++++++++++++++++++++++++++++++ src/php/ext/grpc/package.xml | 82 ++++++++++++++++++++++++++++++++++++ 6 files changed, 224 insertions(+), 15 deletions(-) create mode 100644 src/php/ext/grpc/CREDITS create mode 100644 src/php/ext/grpc/LICENSE create mode 100644 src/php/ext/grpc/README.md create mode 100644 src/php/ext/grpc/package.xml diff --git a/src/php/README.md b/src/php/README.md index cb9b48aee3a..42ddb2d7317 100644 --- a/src/php/README.md +++ b/src/php/README.md @@ -9,12 +9,11 @@ Pre-Alpha : This gRPC PHP implementation is work-in-progress and is not expected ## ENVIRONMENT -Install `php5` and `php5-dev`. +Prerequisite: PHP 5.5 or later, PHPUnit, pecl -To run the tests, additionally install `phpunit`. - -Alternatively, build and install PHP 5.5 or later from source with standard -configuration options. +```sh +sudo apt-get install php5 php5-dev phpunit php-pear +``` ## Build from Homebrew @@ -48,7 +47,7 @@ $ make check $ sudo make install ``` -Build and install the gRPC C core +Build and install the gRPC C core libraries ```sh $ cd grpc @@ -56,7 +55,13 @@ $ make $ sudo make install ``` -Build the gRPC PHP extension +Install the gRPC PHP extension + +```sh +$ sudo pecl install grpc +``` + +OR ```sh $ cd grpc/src/php/ext/grpc @@ -125,4 +130,3 @@ $ ./bin/run_gen_code_test.sh [linuxbrew]:https://github.com/Homebrew/linuxbrew#installation [gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install [Node]:https://github.com/grpc/grpc/tree/master/src/node/examples - diff --git a/src/php/bin/run_tests.sh b/src/php/bin/run_tests.sh index 551be125144..422757bb44e 100755 --- a/src/php/bin/run_tests.sh +++ b/src/php/bin/run_tests.sh @@ -34,15 +34,31 @@ set -e cd $(dirname $0) default_extension_dir=`php -i | grep extension_dir | sed 's/.*=> //g'` -module_dir=../ext/grpc/modules +if command -v brew >/dev/null && [ -d `brew --prefix`/opt/grpc-php ] +then + # homebrew and the grpc-php formula are installed + extension_dir="-d extension_dir="`brew --prefix`/opt/grpc-php +elif [ ! -e $default_extension_dir/grpc.so ] +then + # the grpc extension is not found in the default PHP extension dir + # try the source modules directory + module_dir=../ext/grpc/modules + if [ ! -d $module_dir ] + then + echo "Please run 'phpize && ./configure && make' from ext/grpc first" + exit 1 + fi -# sym-link in system supplied extensions -for f in $default_extension_dir/*.so -do - ln -s $f $module_dir/$(basename $f) &> /dev/null || true -done + # sym-link in system supplied extensions + for f in $default_extension_dir/*.so + do + ln -s $f $module_dir/$(basename $f) &> /dev/null || true + done + + extension_dir='-d extension_dir='$module_dir +fi php \ - -d extension_dir=$module_dir \ + $extension_dir \ -d extension=grpc.so \ `which phpunit` -v --debug --strict ../tests/unit_tests diff --git a/src/php/ext/grpc/CREDITS b/src/php/ext/grpc/CREDITS new file mode 100644 index 00000000000..17b94fedc01 --- /dev/null +++ b/src/php/ext/grpc/CREDITS @@ -0,0 +1,3 @@ +Michael Lumish (mlumish@google.com) +Tim Emiola (temiola@google.com) +Stanley Cheung (stanleycheung@google.com) diff --git a/src/php/ext/grpc/LICENSE b/src/php/ext/grpc/LICENSE new file mode 100644 index 00000000000..704b523970a --- /dev/null +++ b/src/php/ext/grpc/LICENSE @@ -0,0 +1,32 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ diff --git a/src/php/ext/grpc/README.md b/src/php/ext/grpc/README.md new file mode 100644 index 00000000000..0ac09e18353 --- /dev/null +++ b/src/php/ext/grpc/README.md @@ -0,0 +1,72 @@ +gRPC PHP Extension +================== + +# Requirements + + * PHP 5.5+ + * [gRPC core library](https://github.com/grpc/grpc) 0.9.1 + +# Installation + +## Install PHP 5 + +``` +$ sudo apt-get install git php5 php5-dev php-pear unzip +``` + +## Compile gRPC Core Library + +Clone the gRPC source code repository + +``` +$ git clone https://github.com/grpc/grpc.git +``` + +Build and install the Protocol Buffers compiler (protoc) + +``` +$ # from grpc +$ git checkout --track origin/release-0_9 +$ git pull --recurse-submodules && git submodule update --init --recursive +$ cd third_party/protobuf +$ ./autogen.sh +$ ./configure +$ make +$ make check +$ sudo make install +``` + +Build and install the gRPC C core library + +```sh +$ # from grpc +$ make +$ sudo make install +``` + +## Install the gRPC PHP extension + +Quick install + +```sh +$ sudo pecl install grpc +``` + +Note: before a stable release, you may need to do + +```sh +$ sudo pecl install grpc-0.5.0 +``` + +OR + +Compile from source + +```sh +$ # from grpc +$ cd src/php/ext/grpc +$ phpize +$ ./configure +$ make +$ sudo make install +``` diff --git a/src/php/ext/grpc/package.xml b/src/php/ext/grpc/package.xml new file mode 100644 index 00000000000..2c89829d512 --- /dev/null +++ b/src/php/ext/grpc/package.xml @@ -0,0 +1,82 @@ + + + grpc + pecl.php.net + A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. + Remote Procedure Calls (RPCs) provide a useful abstraction for building distributed applications and services. The libraries in this repository provide a concrete implementation of the gRPC protocol, layered over HTTP/2. These libraries enable communication between clients and servers using any combination of the supported languages. + + Stanley Cheung + stanleycheung + grpc-packages@google.com + yes + + 2015-06-16 + + + 0.5.0 + 0.5.0 + + + alpha + alpha + + BSD + +First alpha release + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.5.0 + + + 1.4.0 + + + + grpc + + + + + 0.5.0 + 0.5.0 + + + alpha + alpha + + 2015-06-16 + BSD + +First alpha release + + + +