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.
C implementation
To install and configure the Protobuf PHP extension:
Run sudo pecl install protobuf from the command line.
Add an extension=protobuf.so line to the php.ini file.
PHP implementation
Make sure the C implementation is disabled and all the dependencies of
the googleapis/gax-php library are
installed:
Comment out any extension=protobuf.so line in php.ini.
Run composer install from the directory that contains the
composer.json file of the project being worked on. The composer.json
should specify google-ads-php 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
using Composer).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-28 UTC."],[[["The Google Ads API for PHP offers two implementations: C (for performance) and PHP (for ease of use)."],["The C implementation utilizes the Protobuf PHP extension and requires manual installation via `pecl` and `php.ini` configuration."],["The PHP implementation is automatically installed with `googleapis/gax-php` dependencies but is used only if the C implementation is unavailable."],["Users can determine the active implementation by running `php -i | grep protobuf`."]]],[]]