vitess-gh/php
Alain Jobart 0e1a4f1df4 Also fixing PHP client. 2015-11-05 07:36:38 -08:00
..
src Also fixing PHP client. 2015-11-05 07:36:38 -08:00
tests Migrating from go's Session to proto3 Session. 2015-11-04 10:29:51 -08:00
README.md Update README.md 2015-10-16 10:54:19 -07:00
composer.json php/grpc: Add composer config for downloading gRPC dependencies. 2015-10-07 13:17:32 -07:00
composer.lock php/grpc: Add composer config for downloading gRPC dependencies. 2015-10-07 13:17:32 -07:00
demo.php Use gRPC for PHP client. 2015-10-16 00:07:02 -07:00

README.md

Vitess PHP

This folder contains the PHP client for Vitess.

See demo.php for a simple example of using the API.

Prerequisites

PHP 5.5+ is required.

gRPC Extension Module

Install the gRPC extension module.

For example, on Debian/Ubuntu:

$ sudo apt-get install php5-dev php5-cli php-pear
$ sudo pecl install grpc-beta

gRPC Dependencies

To download the dependencies of the gRPC PHP library, run Composer:

$ cd vitess/php
vitess/php$ curl -sS https://getcomposer.org/installer | php
vitess/php$ php composer.phar install

Unit Tests

To run the tests, first install PHPUnit:

$ wget https://phar.phpunit.de/phpunit-4.8.9.phar
$ mv phpunit-4.8.9.phar $VTROOT/bin/phpunit
$ chmod +x $VTROOT/bin/phpunit

Then run the tests like this:

vitess$ . dev.env
vitess$ make php_test

Coverage

In addition to PHPUnit, you also need to install xdebug, if you want to see coverage:

$ sudo pecl install xdebug
[...]
Build process completed successfully
Installing '/usr/lib/php5/20121212/xdebug.so'

# Where should we put the ini file?
$ php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d

# Make an ini file for xdebug.
$ sudo sh -c "echo \"zend_extension=$(pecl config-get ext_dir default)/xdebug.so\" > /etc/php5/cli/conf.d/20-xdebug.ini"

# Check that xdebug is being loaded.
$ php -m | grep xdebug
xdebug

Then you can run a coverage check with PHPUnit:

vitess/php$ phpunit --coverage-html _test tests

# Open in browser.
vitess/php$ xdg-open _test/index.html