PHPackages                             forkiss/grpc-pithy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. forkiss/grpc-pithy

ActiveLibrary[API Development](/categories/api)

forkiss/grpc-pithy
==================

gRPC library for PHP - for Developement use only

011PHP

Since Mar 26Pushed 8y ago1 watchersCompare

[ Source](https://github.com/forkiss/grpc-pithy)[ Packagist](https://packagist.org/packages/forkiss/grpc-pithy)[ RSS](/packages/forkiss-grpc-pithy/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Overview
========

[](#overview)

This directory contains source code for PHP implementation of gRPC layered on shared C library.

Environment
-----------

[](#environment)

**Prerequisite:**

- `php` 5.5 or above, 7.0 or above
- `pecl`
- `composer`
- `phpunit` (optional)

**Install PHP and PECL on Ubuntu/Debian:**

For PHP5:

```
$ sudo apt-get install php5 php5-dev php-pear phpunit
```

For PHP7:

```
$ sudo apt-get install php7.0 php7.0-dev php-pear phpunit
```

**Install PHP and PECL on CentOS/RHEL 7:**

```
$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
$ sudo yum install php56w php56w-devel php-pear phpunit gcc zlib-devel
```

**Install PECL on Mac:**

```
$ curl -O http://pear.php.net/go-pear.phar
$ sudo php -d detect_unicode=0 go-pear.phar
```

**Install Composer (Linux or Mac):**

```
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
```

**Install PHPUnit (Linux or Mac):**

```
$ wget https://phar.phpunit.de/phpunit-old.phar
$ chmod +x phpunit-old.phar
$ sudo mv phpunit-old.phar /usr/bin/phpunit
```

Quick Install
-------------

[](#quick-install)

**Install the gRPC PHP extension**

```
sudo pecl install grpc
```

This will compile and install the gRPC PHP extension into the standard PHP extension directory. You should be able to run the [unit tests](#unit-tests), with the PHP extension installed.

Note: For users on CentOS/RHEL 6, unfortunately this step won't work. Please follow the instructions below to compile the extension from source.

**Update php.ini**

Add this line to your `php.ini` file, e.g. `/etc/php5/cli/php.ini`

```
extension=grpc.so
```

**Add the gRPC PHP library as a Composer dependency**

You need to add this to your project's `composer.json` file.

```
  "require": {
    "grpc/grpc": "v1.1.0"
  }

```

To run tests with generated stub code from `.proto` files, you will also need the `composer` and `protoc` binaries. You can find out how to get these [below](#generated-code-tests).

Build from Source
-----------------

[](#build-from-source)

### gRPC C core library

[](#grpc-c-core-library)

Clone this repository

```
$ git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc
```

Build and install the gRPC C core library

```
$ cd grpc
$ git pull --recurse-submodules && git submodule update --init --recursive
$ make
$ sudo make install
```

### gRPC PHP extension

[](#grpc-php-extension)

Compile the gRPC PHP extension

```
$ cd grpc/src/php/ext/grpc
$ phpize
$ ./configure
$ make
$ sudo make install
```

Unit Tests
----------

[](#unit-tests)

You will need the source code to run tests

```
$ git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git pull --recurse-submodules && git submodule update --init --recursive
```

Run unit tests

```
$ cd grpc/src/php
$ ./bin/run_tests.sh
```

Generated Code Tests
--------------------

[](#generated-code-tests)

This section specifies the prerequisites for running the generated code tests, as well as how to run the tests themselves.

### Composer

[](#composer)

Install the runtime dependencies via `composer install`.

```
$ cd grpc/src/php
$ composer install
```

### Protobuf compiler

[](#protobuf-compiler)

Again if you don't have it already, you need to install the protobuf compiler `protoc`, version 3.1.0+ (the newer the better).

If `protoc` hasn't been installed, you can download the `protoc` binaries from [the protocol buffers Github repository](https://github.com/google/protobuf/releases).

If you really must compile `protoc` from source, you can run the following commands, but this is risky because there is no easy way to uninstall / upgrade to a newer release.

```
$ cd grpc/third_party/protobuf
$ ./autogen.sh && ./configure && make
$ sudo make install
```

### Protobuf Runtime library

[](#protobuf-runtime-library)

There are two protobuf runtime libraries to choose from. They are idenfical in terms of APIs offered.

1. C implementation (for better performance)

```
$ sudo pecl install protobuf
```

2. PHP implementation (for easier installation)

Add this to your `composer.json` file:

```
  "require": {
    "google/protobuf": "^v3.3.0"
  }

```

### PHP Protoc Plugin

[](#php-protoc-plugin)

You need the gRPC PHP protoc plugin to generate the client stub classes.

It should already been compiled when you run `make` from the root directory of this repo. The plugin can be found in the `bins/opt` directory. We are planning to provide a better way to download and install the plugin in the future.

You can also just build the gRPC PHP protoc plugin by running:

```
$ cd grpc
$ make grpc_php_plugin
```

### Client Stub

[](#client-stub)

Generate client stub classes from `.proto` files

```
$ cd grpc/src/php
$ ./bin/generate_proto_php.sh
```

### Run test server

[](#run-test-server)

Run a local server serving the math services. Please see [Node](https://github.com/grpc/grpc/tree/master/src/node/examples) for how to run an example server.

```
$ cd grpc
$ npm install
$ node src/node/test/math/math_server.js
```

### Run test client

[](#run-test-client)

Run the generated code tests

```
$ cd grpc/src/php
$ ./bin/run_gen_code_test.sh
```

Use the gRPC PHP extension with Apache
--------------------------------------

[](#use-the-grpc-php-extension-with-apache)

Install `apache2`, in addition to `php5` above

```
$ sudo apt-get install apache2
```

Add this line to your `php.ini` file, e.g. `/etc/php5/apache2/php.ini`or `/etc/php/7.0/apache2/php.ini`

```
extension=grpc.so
```

Restart apache

```
$ sudo service apache2 restart
```

Make sure the Node math server is still running, as above.

```
$ cd grpc
$ npm install
$ node src/node/test/math/math_server.js
```

Make sure you have run `composer install` to generate the `vendor/autoload.php` file

```
$ cd grpc/src/php
$ composer install
```

Make sure you have generated the client stubs

```
$ ./bin/generate_proto_php.sh
```

Copy the `math_client.php` file into your Apache document root, e.g.

```
$ cp tests/generated_code/math_client.php /var/www/html
```

You may have to fix the first line to point the includes to your installation:

```
include 'vendor/autoload.php';
```

Connect to `localhost/math_client.php` in your browser, or run this from command line:

```
$ curl localhost/math_client.php
```

Use the gRPC PHP extension with Nginx/PHP-FPM
---------------------------------------------

[](#use-the-grpc-php-extension-with-nginxphp-fpm)

Install `nginx` and `php5-fpm`, in addition to `php5` above

```
$ sudo apt-get install nginx php5-fpm

OR

$ sudo apt-get install nginx php7.0-fpm
```

Add this line to your `php.ini` file, e.g. `/etc/php5/fpm/php.ini`

```
extension=grpc.so
```

Uncomment the following lines in your `/etc/nginx/sites-available/default` file:

```
location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
}

```

Restart nginx and php-fpm

```
$ sudo service nginx restart
$ sudo service php5-fpm restart
```

Make sure the Node math server is still running, as above.

```
$ cd grpc
$ npm install
$ node src/node/test/math/math_server.js
```

Make sure you have run `composer install` to generate the `vendor/autoload.php` file

```
$ cd grpc/src/php
$ composer install
```

Make sure you have generated the client stubs

```
$ ./bin/generate_proto_php.sh
```

Copy the `math_client.php` file into your Nginx document root, e.g.

```
$ cp tests/generated_code/math_client.php /var/www/html
```

You may have to fix the first line to point the includes to your installation:

```
include 'vendor/autoload.php';
```

Connect to `localhost/math_client.php` in your browser, or run this from command line:

```
$ curl localhost/math_client.php
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a19c678aa3acbd50bdc63985077b1419f3f7243c497c2a0d7486d5ca8cbc7afa?d=identicon)[forkiss](/maintainers/forkiss)

### Embed Badge

![Health badge](/badges/forkiss-grpc-pithy/health.svg)

```
[![Health](https://phpackages.com/badges/forkiss-grpc-pithy/health.svg)](https://phpackages.com/packages/forkiss-grpc-pithy)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
