Add support for GNU Multiple Precision (GMP) PHP extension.

The extension is not available for PHP 5.2 because it does not support
latest libgmp versions.

Fixes #141.
Enable Zend Thread Safety for PHP.

Fixes travis-ci/travis-ci#917.