Transport

  • The Google Ads API client library supports two transport types: gRPC (preferred) and REST (fallback).

  • gRPC offers better performance but requires the gRPC PHP extension, while REST is based on HTTP/1.1 and doesn't require any specific extension.

  • You can manually specify your preferred transport type through the google_ads_php.ini configuration file or programmatically within your code.

  • The gRPC version utilized by the library is usually managed through dependencies, primarily google/gax, and occasionally directly within the library's own composer.json for optimization or compatibility.

There are two types of transport that can be used when sending requests to the API. Our client library selects the optimal one from the following:

  • Preferred: gRPC. It requires the installation of the gRPC PHP extension and it is based on HTTP/2.
  • Alternative used when gRPC is not available: REST. It does not require the installation of any PHP extension and it is based on HTTP/1.1.

If you prefer to specify the transport type yourself instead of relying on the default rules described above, you can set the transport property in the CONNECTION section of your google_ads_php.ini file:

[CONNECTION]
; Optional transport settings.
; By default, "grpc" is used if available otherwise "rest".
transport = "grpc"

Alternatively, you can configure the transport setting programmatically like every other ones:

$googleAdsClient = (new GoogleAdsClientBuilder())
    ...
    ->withTransport('grpc')
    ->build();