PHPackages                             dagyrazev/google-ads-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dagyrazev/google-ads-php

ActiveLibrary

dagyrazev/google-ads-php
========================

Google Ads API client for PHP 7.0.3

v3.2.0(6y ago)071Apache-2.0PHPPHP &gt;=7.2

Since Jun 6Pushed 5y agoCompare

[ Source](https://github.com/dagryazev/google-ads-php)[ Packagist](https://packagist.org/packages/dagyrazev/google-ads-php)[ RSS](/packages/dagyrazev-google-ads-php/feed)WikiDiscussions dev-fix-php Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (145)Used By (0)

Google Ads API Client Library for PHP
=====================================

[](#google-ads-api-client-library-for-php)

[![Minimum PHP Version](https://camo.githubusercontent.com/824c5c4ccb56537db3b3b53bb43d7b8edc6286f3b3d1705525e0821dfd22d27e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e312d3838393242462e737667)](https://www.php.net/supported-versions.php)[![Latest Stable Version](https://camo.githubusercontent.com/7162410daa2effad449541c56d43a890ae364a1df36db9e4a48d527b78782e3a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676f6f676c656164732f676f6f676c652d6164732d7068702e737667)](https://packagist.org/packages/googleads/google-ads-php)[![Total Downloads](https://camo.githubusercontent.com/906c10d95b9d85dd7c285931f060287a9f86203035b532ab7c970604e2b58cfd/68747470733a2f2f706f7365722e707567782e6f72672f676f6f676c656164732f676f6f676c652d6164732d7068702f646f776e6c6f6164732e737667)](https://packagist.org/packages/googleads/google-ads-php)[![License](https://camo.githubusercontent.com/31e91c4fc86606e73d5d6780ce24b35ffa958eac3825553459c2a47d397ead4a/68747470733a2f2f706f7365722e707567782e6f72672f676f6f676c656164732f676f6f676c652d6164732d7068702f6c6963656e73652e737667)](https://packagist.org/packages/googleads/google-ads-php)

[![Build Status](https://camo.githubusercontent.com/21edfa5fa16559848cd84aeb9f4dfd3f4d1669ef282b637a2e31d958d4715dc1/68747470733a2f2f7472617669732d63692e6f72672f676f6f676c656164732f676f6f676c652d6164732d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/googleads/google-ads-php)[![codecov](https://camo.githubusercontent.com/87c90c569a40134a12b6d8cc1e1870731d74de6e08cf5fb402c659fb0285084f/68747470733a2f2f636f6465636f762e696f2f67682f676f6f676c656164732f676f6f676c652d6164732d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/googleads/google-ads-php)

This project hosts the PHP client library for the [Google Ads API](https://developers.google.com/google-ads/api/docs/start).

Features
--------

[](#features)

- Distributed via [Composer](https://getcomposer.org/) and [Packagist](https://packagist.org/packages/googleads/google-ads-php).
- Easy management of credentials.
- Easy creation of Google Ads API service clients.

Requirements
------------

[](#requirements)

- This library depends on [Composer](https://getcomposer.org/). If you don't have it installed on your computer yet, follow the [installation guide for Linux/Unix/OS X](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) or [installation guide for Windows](https://getcomposer.org/doc/00-intro.md#installation-windows). For the rest of this guide, we're assuming that you're using Linux/Unix/OS X and have Composer installed [globally](https://getcomposer.org/doc/00-intro.md#globally), thus, your installed Composer is available on the command line as `composer`.
- System requirements and dependencies can be found in [composer.json](composer.json) of this library.
    - The minimum required PHP version of this library is the minimum PHP version for which the PHP development team still provide security fixes. Whenever such a version is sunset, we'll update the composer file accordingly. Currently, the update frequency is around once a year based on the [official schedule](https://www.php.net/supported-versions.php).
    - To install the gRPC PHP extension, follow the section **Install the gRPC PHP extension**of [this page](https://grpc.io/docs/quickstart/php.html).
        1. Install the extension using the command `sudo pecl install grpc`.
        2. Add a line `extension=grpc.so` to the `php.ini` file.
        3. Run `php -i | grep grpc` in a terminal: it is well installed and configured if it returns something
    - To install the Protobuf PHP extension, follow the section **C implementation** under **Protobuf Runtime library** of [this page](https://grpc.io/docs/quickstart/php.html). If you encounter any error you can skip this step and the PHP implementation will be used instead. More details can be found in the [Protobuf section](#protobuf).
        1. Install the extension using the command `sudo pecl install protobuf`.
        2. Add a line `extension=protobuf.so` to the `php.ini` file.
        3. Run `php -i | grep protobuf` in a terminal: it is well installed and configured if it returns something
- You need a [developer token](https://developers.google.com/google-ads/api/docs/first-call/dev-token)to connect to the Google Ads API.

Getting started
---------------

[](#getting-started)

1. Clone this project in the directory of your choice via:

    ```
    git clone https://github.com/googleads/google-ads-php.git

    ```
2. Change into the `google-ads-php` directory.

    ```
    cd google-ads-php

    ```

    You'll see some files and subdirectories:

    - `composer.json`: the composer file, which holds the requirements of this library.
    - `src`: source code of the library.
    - `tests`: tests of the library code.
    - `examples`: many examples that demonstrate how to use the library to execute common use cases via the Google Ads API.
    - `metadata`: some metadata files used internally by the source code. They're automatically generated files, so you shouldn't modify them.
3. Run `composer install` at the command prompt. This will install all dependencies needed for using the library and running examples.
4. Set up your OAuth2 credentials.

    The Google Ads API uses [OAuth2](http://oauth.net/2/) as the authentication mechanism. Choose the appropriate option below based on your use case, and read and follow the instructions that the example prints to the console.

    **If you already have credentials for the AdWords API...**

    - If you have the `adsapi_php.ini` file you used for the AdWords API, copy and name it as `google_ads_php.ini`. Simply change the section name from `[ADWORDS]` to `[GOOGLE_ADS]`.
    - If you don't have the file, copy the sample `google_ads_php.ini` to your [home directory](https://en.wikipedia.org/wiki/Home_directory#Default_home_directory_per_operating_system). This library determines the home directory of your computer by using [`EnvironmentalVariables::getHome()`](https://github.com/googleads/google-ads-php/blob/master/src/Google/Ads/GoogleAds/Util/EnvironmentalVariables.php#L36).

    **If you're accessing the Google Ads API using your own credentials...**

    - Copy the sample [`google_ads_php.ini`](examples/Authentication/google_ads_php.ini)to your [home directory](https://en.wikipedia.org/wiki/Home_directory#Default_home_directory_per_operating_system). This library determines the home directory of your computer by using [`EnvironmentalVariables::getHome()`](https://github.com/googleads/google-ads-php/blob/master/src/Google/Ads/GoogleAds/Util/EnvironmentalVariables.php#L36).
    - Follow the instructions at  to create an OAuth2 client ID and secret for the **installed application**OAuth2 flow.
    - Run the [AuthenticateInStandaloneApplication](https://github.com/googleads/google-ads-php/blob/master/examples/Authentication/AuthenticateInStandaloneApplication.php)example, which will prompt you for your OAuth2 client ID and secret.
    - Copy the output from the last step of the example into the `google_ads_php.ini` file in your home directory. Don't forget to fill in your developer token too.
5. Run the [GetCampaigns example](examples/BasicOperations/GetCampaigns.php) to test if your credentials are valid. You also need to pass your Google Ads account's customer ID without dashes as a command-line parameter:

    ```
    php examples/BasicOperations/GetCampaigns.php --customerId

    ```

    **NOTE**: Code examples are meant to be run from command prompt, not via the web browsers.
6. Explore other examples.

    The [examples](examples) directory contains several useful examples. Most of the examples require parameters. You can see what are required by running code examples with `--help` as a command-line parameter.

Basic usage
-----------

[](#basic-usage)

To issue requests via the Google Ads API, you first need to create a [GoogleAdsClient](https://github.com/googleads/google-ads-php/blob/master/src/Google/Ads/GoogleAds/Lib/V1/GoogleAdsClient.php). For convenience, you can store the required settings in a properties file (`google_ads_php.ini`) with the following format:

```
[GOOGLE_ADS]
developerToken = "INSERT_DEVELOPER_TOKEN_HERE"

[OAUTH2]
clientId = "INSERT_OAUTH2_CLIENT_ID_HERE"
clientSecret = "INSERT_OAUTH2_CLIENT_SECRET_HERE"
refreshToken = "INSERT_OAUTH2_REFRESH_TOKEN_HERE"

```

If you're authenticating as a manager account, additionally you must specify the manager account ID (with hyphens removed) as the login customer ID:

```
[GOOGLE_ADS]
loginCustomerId = "INSERT_LOGIN_CUSTOMER_ID_HERE"

```

This configuration file format is similar to the format used in the AdWords API's [client library for PHP](https://github.com/googleads/googleads-php-lib).

If you have a `google_ads_php.ini` configuration file in the above format in your home directory, you can use the no-arg version of `fromFile()` as follows:

```
$googleAdsClient = (new GoogleAdsClientBuilder())
    ->fromFile()
    ->withOAuth2Credential($oAuth2Credential)
    ->build();
```

where `$oAuth2Credential` was created by:

```
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
```

If your configuration file is not in your home directory, you can pass the file location to the `fromFile` methods as follows:

```
$oAuth2Credential = (new OAuth2TokenBuilder())
    ->fromFile('/path/to/google_ads_php.ini')
    ->build();
$googleAdsClient = (new GoogleAdsClientBuilder())
    ->fromFile('/path/to/google_ads_php.ini')
    ->withOAuth2Credential($oAuth2Credential)
    ->build();
```

You can also construct an OAuth2 credential object by specifying the client ID, client secret, and refresh token at runtime, then pass that to the `GoogleAdsClientBuilder` as follows:

```
$oAuth2Credential = (new OAuth2TokenBuilder())
    ->withClientId('INSERT_CLIENT_ID')
    ->withClientSecret('INSERT_CLIENT_SECRET')
    ->withRefreshToken('INSERT_REFRESH_TOKEN')
    ->build();
$googleAdsClient = (new GoogleAdsClientBuilder())
    ->withOAuth2Credential($oAuth2Credential)
    ->withDeveloperToken('INSERT_DEVELOPER_TOKEN_HERE')
    ->withLoginCustomerId('INSERT_LOGIN_CUSTOMER_ID_HERE')
    ->build();
```

### Get a service client

[](#get-a-service-client)

Once you have an instance of `GoogleAdsClient`, you can obtain a service client for a particular service using one of the `get...ServiceClient()` methods.

Transport
---------

[](#transport)

There are different types of transport that can be used. See the [Transport guide](https://developers.google.com/google-ads/api/docs/client-libs/php/transport)for more information.

Protobuf
--------

[](#protobuf)

[Protobuf](https://developers.google.com/protocol-buffers/docs/overview) is used regardless of the transport used to request the Google Ads API.

See the [Protobuf guide](https://developers.google.com/google-ads/api/docs/client-libs/php/protobuf)for more information.

Running in a Docker container
-----------------------------

[](#running-in-a-docker-container)

See the [Running in a Docker container guide](https://developers.google.com/google-ads/api/docs/client-libs/php/docker).

Logging
-------

[](#logging)

See the [Logging guide](https://developers.google.com/google-ads/api/docs/client-libs/php/logging).

Proxy configuration
-------------------

[](#proxy-configuration)

See the [Proxy guide](https://developers.google.com/google-ads/api/docs/client-libs/php/proxy).

Performance
-----------

[](#performance)

See the [Performance guide](https://developers.google.com/google-ads/api/docs/client-libs/php/performance).

Miscellaneous
-------------

[](#miscellaneous)

### Wiki

[](#wiki)

-

### Issue tracker

[](#issue-tracker)

-

### API Documentation:

[](#api-documentation)

-

### Support forum

[](#support-forum)

-

### Authors

[](#authors)

- [Thanet Knack Praneenararat](https://github.com/fiboknacky)
- [Mattia Tommasone](https://github.com/Raibaz)
- [Pierrick Voulet](https://github.com/PierrickVoulet)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Recently: every ~60 days

Total

22

Last Release

2025d ago

Major Versions

v0.7.0 → v1.0.02019-03-05

v1.4.1 → v2.0.02019-07-01

v2.2.0 → v3.0.02019-12-16

PHP version history (3 changes)0.1.0PHP &gt;=5.5.9 || ^7.0

v1.0.0PHP &gt;=7.1

v3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fa807fade25cdff22274f5f75a488aa573bc8229b16100a79cb072e21768660?d=identicon)[dagryzev](/maintainers/dagryzev)

---

Top Contributors

[![fiboknacky](https://avatars.githubusercontent.com/u/1702801?v=4)](https://github.com/fiboknacky "fiboknacky (132 commits)")[![PierrickVoulet](https://avatars.githubusercontent.com/u/6769971?v=4)](https://github.com/PierrickVoulet "PierrickVoulet (76 commits)")[![Raibaz](https://avatars.githubusercontent.com/u/1030142?v=4)](https://github.com/Raibaz "Raibaz (46 commits)")[![dagryazev](https://avatars.githubusercontent.com/u/42826073?v=4)](https://github.com/dagryazev "dagryazev (9 commits)")[![alexeyshockov](https://avatars.githubusercontent.com/u/203120?v=4)](https://github.com/alexeyshockov "alexeyshockov (2 commits)")[![stevenberger](https://avatars.githubusercontent.com/u/2490931?v=4)](https://github.com/stevenberger "stevenberger (2 commits)")[![mackenziestarr](https://avatars.githubusercontent.com/u/6363360?v=4)](https://github.com/mackenziestarr "mackenziestarr (1 commits)")[![makstech](https://avatars.githubusercontent.com/u/25028046?v=4)](https://github.com/makstech "makstech (1 commits)")[![michaelbausor](https://avatars.githubusercontent.com/u/14846209?v=4)](https://github.com/michaelbausor "michaelbausor (1 commits)")[![oniltos](https://avatars.githubusercontent.com/u/1441749?v=4)](https://github.com/oniltos "oniltos (1 commits)")[![imerenanu](https://avatars.githubusercontent.com/u/24648962?v=4)](https://github.com/imerenanu "imerenanu (1 commits)")[![bbsnly](https://avatars.githubusercontent.com/u/8020430?v=4)](https://github.com/bbsnly "bbsnly (1 commits)")[![kurorido](https://avatars.githubusercontent.com/u/300858?v=4)](https://github.com/kurorido "kurorido (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/dagyrazev-google-ads-php/health.svg)

```
[![Health](https://phpackages.com/badges/dagyrazev-google-ads-php/health.svg)](https://phpackages.com/packages/dagyrazev-google-ads-php)
```

###  Alternatives

[googleads/google-ads-php

Google Ads API client for PHP

3497.6M9](/packages/googleads-google-ads-php)[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

81733.7k](/packages/flow-php-flow)[chh/pipe

Put your assets into the Pipe and smoke them.

1212.5k1](/packages/chh-pipe)[drevops/git-artifact

Package artifact from your codebase in CI and push it to a separate git repo.

2133.2k](/packages/drevops-git-artifact)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
