There are two implementations that are available for PHP:
- C: Uses the Protobuf PHP extension which gives better performance.
- PHP: Uses the
google/protobufPHP package which is easier to implement.
We recommend using the C implementation if you can, but PHP may be needed in some cases (such as when limited by security or technical constraints).
The PHP implementation is automatically installed like any other
googleapis/gax-php dependencies in
Composer, but it is used at runtime only if the C implementation is not
installed and configured.
To install and configure the Protobuf PHP extension:
sudo pecl install protobuffrom the command line.
- Add an
extension=protobuf.soline to the
Make sure the C implementation is disabled and all the dependencies of
googleapis/gax-php library are
- Comment out any
composer installfrom the directory that contains the
composer.jsonfile of the project being worked on. The
google-ads-phpor any project that requires it as a dependence.
Determine which implementation is being used
php -i | grep protobuf:
- If not empty, you're using the C implementation.
- Otherwise, you're not using the C implementation and the Google Ads API PHP library will rely on the PHP implementation (if installed correctly using Composer).