There are two implementations that are available for PHP:
- C: the Protobuf PHP extension for better performance
- PHP: the
google/protobuf
PHP package to get started easily
We recommend to use the C implementation but some users might need the PHP implementation instead because of security or technical constraint for examples.
The PHP implementation is automatically installed like any
other googleapis/gax-php
dependencies via Composer but it is used at runtime only if the C implementation is not installed
and configured.
Use the C implementation
Install and configure the Protobuf PHP extension:
- Run command
sudo pecl install protobuf
. - Add a line
extension=protobuf.so
to thephp.ini
file.
Use the PHP implementation
Make sure the C implementation is disabled and all the dependencies of
the googleapis/gax-php
library are installed:
- Comment out the
extension=protobuf.so
line of thephp.ini
file if any. - Run command
composer install
in the directory that contains thecomposer.json
file of the project being worked on (google-ads-php
itself or any project that requires it as a dependence).
Determine which implementation is being used
Run 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 via Composer)