ea12c8f0f6
This addresses #2723. This change is essentially a new protocol for V3. Although backward compatible, it changes the connection model. Basically, the newer V3 features will work only if you used the new protocol. The new model deprecates keyspace_shard, tablet_type and options from ExecuteRequest and moves them into the Session. This means that the Session is generally not empty, and may be updated by any call to Execute or ExecuteBatch, even if the statements are not transactional. Consequently, transactional methods like Begin, etc. are deprecated in favor of Execute("begin"). Transaction modes will now be supported by new `SET` syntax, which will correspondingly update the Session variable. This also makes a connection that contains a session non-multiplexable. We'll need to resolve whether it's still worth exposing this flexibility to the clients, and if so, how. For now, I've updated the Go driver to use the "modern" protocol. However, the low level rpc (Impl) continues to support the older functions like Begin, etc. This allows us to test the legacy functionality. All other clients: Python, PHP and Java are currently unchanged. Given that this is a major protocol change, it hints at a 3.0, but the changes are 2.1 compatible with the following exceptions: * Go driver uses the new protocol. * vtclient binary requires `-target` instead of `-tablet-type`, etc. All tests are passing including PHP & Java clients. In terms of upgrade: * PHP and Java can be upgraded by just updating the code. * Python will probably require a brand new library. The existing vtdb contains way too much baggage, and it may not be worth retrofitting this new incompatible protocol onto what's currently there. I'm looking for a name. `vtdb2`, `vitessdb`? |
||
---|---|---|
.. | ||
pdo@5bd671c129 | ||
src | ||
tests | ||
README.md |
README.md
Vitess PHP
This folder contains the PHP client for Vitess.
For a simple example of using the API, see the [client.php] (https://github.com/youtube/vitess/blob/master/examples/local/client.php) script, which works with the environment created by the [local setup example] (http://vitess.io/getting-started/local-instance.html).
There is also a similar example client for the [VTGateV3 demo] (https://github.com/youtube/vitess/tree/master/examples/demo) environment.
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
gRPC Dependencies
To download the dependencies of the gRPC PHP library, run Composer:
$ cd vitess
vitess$ curl -sS https://getcomposer.org/installer | php
vitess$ 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$ phpunit --coverage-html php/_test
# Open in browser.
vitess$ xdg-open php/_test/index.html