Transport

  • The API supports two transport types, gRPC and REST, with the client library automatically selecting the optimal one.

  • gRPC is the preferred transport, requiring a PHP extension and based on HTTP/2, while REST is an alternative based on HTTP/1.1 that needs no extension.

  • You can manually specify the transport type in the google_ads_php.ini file or programmatically using the GoogleAdsClientBuilder.

  • The gRPC version is typically specified in google/gax's composer.json, though the PHP library may sometimes directly specify the protobuf version for performance or compatibility.

There are two types of transport that can be used when sending requests to the API. The PHP client library automatically selects the optimal transport based on your environment:

  • Preferred (grpc): gRPC. It requires installing the gRPC PHP extension and is based on HTTP/2.
  • Fallback (rest): REST. Used automatically when the gRPC extension is not available. It does not require installing any additional PHP extensions and is based on HTTP/1.1.

Configure transport

If you prefer to explicitly specify the transport type (grpc or rest) instead of relying on the default automatic selection rules described in the preceding section, you can configure the transport setting in your google_ads_php.ini file or programmatically.

Configure in google_ads_php.ini

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" is used.
transport = "grpc"

Configure programmatically

Alternatively, you can configure the transport setting programmatically when constructing the client:

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