PHPackages                             spirit-act/googleads-php-lib - 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. [API Development](/categories/api)
4. /
5. spirit-act/googleads-php-lib

ActiveLibrary[API Development](/categories/api)

spirit-act/googleads-php-lib
============================

Google Ad Manager SOAP API Client Library for PHP

71.0.0(4mo ago)063Apache-2.0PHPPHP &gt;=8

Since Jul 17Pushed 4mo agoCompare

[ Source](https://github.com/Spirit-act/googleads-php-lib)[ Packagist](https://packagist.org/packages/spirit-act/googleads-php-lib)[ Docs](https://github.com/googleads/googleads-php-lib)[ RSS](/packages/spirit-act-googleads-php-lib/feed)WikiDiscussions fork Synced 1mo ago

READMEChangelogDependencies (9)Versions (11)Used By (0)

Google Ad Manager SOAP API Client Library for PHP
-------------------------------------------------

[](#google-ad-manager-soap-api-client-library-for-php)

This repository hosts the PHP client library for the Google Ad Manager SOAP API.

> **The AdWords API is [sunset](https://ads-developers.googleblog.com/2022/04/reminder-requests-to-adwords-api-will.html). You can use the new client library [google-ads-php](https://github.com/googleads/google-ads-php) to access the new [Google Ads API](https://developers.google.com/google-ads/api/docs/start) instead.**

[![Minimum PHP Version](https://camo.githubusercontent.com/905c670b6e3bc20026bddbc8923df4d38111e526b88f1252ac4ceb6643299d96/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e302d3838393242462e737667)](https://www.php.net/supported-versions.php)[![Latest Stable Version](https://camo.githubusercontent.com/a957a745df8a05f73773107716bd78b91415694f51ae4587cc508cf6b7362cab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676f6f676c656164732f676f6f676c656164732d7068702d6c69622e737667)](https://packagist.org/packages/googleads/googleads-php-lib)[![Total Downloads](https://camo.githubusercontent.com/8ac74ec183dd2cb7da7042b39f177d76a3cff4c2d153a0c5c4e6f61d37693afe/68747470733a2f2f706f7365722e707567782e6f72672f676f6f676c656164732f676f6f676c656164732d7068702d6c69622f646f776e6c6f6164732e737667)](https://packagist.org/packages/googleads/googleads-php-lib)[![License](https://camo.githubusercontent.com/a238fc271f2ec2468df95be1bf5582aa437fcd8b36687e256691cdd6cb1c056b/68747470733a2f2f706f7365722e707567782e6f72672f676f6f676c656164732f676f6f676c656164732d7068702d6c69622f6c6963656e73652e737667)](https://packagist.org/packages/googleads/googleads-php-lib)

**IMPORTANT** This client library has been updated to require PHP version 8.0 as the minimum version, as announced in [\#777](https://github.com/googleads/googleads-php-lib/issues/777). This means that the final version of the library that supports PHP 7 is [v61.0.0](https://github.com/googleads/googleads-php-lib/releases/tag/v61.0.0), which supports Google Ad Manager API v202208, v202211, v202302, and v202305.

Google Ad Manager API v202305 is [scheduled to be sunset in May 2024](https://developers.google.com/ad-manager/api/deprecation). Therefore, PHP 7 users have about a year to migrate to the version 8.0 or higher of PHP to avoid disruption.

### Requirements and Preparation

[](#requirements-and-preparation)

- System requirements and dependencies can be found in `composer.json` of this library. See [this page](https://getcomposer.org/doc/01-basic-usage.md) for more details.
- From version 62.0.0, this library requires the minimum PHP version to be 8.0. If you have an older version of PHP, `composer` command will download an older version of the `googleads/googleads-php-lib` library.
- 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`.

### Getting started

[](#getting-started)

Copy the sample [Ad Manager adsapi\_php.ini](https://github.com/googleads/googleads-php-lib/blob/HEAD/examples/AdManager/adsapi_php.ini)to your [home directory](https://en.wikipedia.org/wiki/Home_directory#Default_home_directory_per_operating_system)and fill out the required properties before downloading the library. This library determines the home directory of your computer by using [`EnvironmentalVariables::getHome()`](https://github.com/googleads/googleads-php-lib/blob/HEAD/src/Google/AdsApi/Common/Util/EnvironmentalVariables.php#L34).

### Downloading this library

[](#downloading-this-library)

There are three ways of downloading this library as described below.

MethodTarget Users[Using `composer require`](#using-composer-require)Those who want to **use this library as a third-party library** for their projects and thus example files are not needed.[Using `git clone`](#using-git-clone)Those who want to **alter or contribute to this library** (e.g., submitting a pull request) or want to **run example files**.[Downloading a compressed tarball](#downloading-a-compressed-tarball)Those who only want to **run example files**.#### Note

[](#note)

- If you don't have OAuth2 credentials prior to using [installed application flow](https://github.com/googleads/googleads-php-lib/wiki/API-access-using-own-credentials-(installed-application-flow)), you'll need [examples/Auth/GetRefreshToken.php](https://github.com/googleads/googleads-php-lib/blob/HEAD/examples/Auth/GetRefreshToken.php). In this case, using `composer require` is not an option since there are no example files downloaded with the library.
- **Our examples are meant to be run from the command line and not as a webpage.** If you run them as a webpage, results may not be shown properly.

### Using composer require

[](#using-composer-require)

The steps below download this library as a third-party library for your projects. The library will be downloaded by Composer and stored under the `vendor/` directory. **Examples are NOT downloaded by this download method.**

1. Install the latest version using [Composer](https://getcomposer.org/).

    ```
    $ composer require googleads/googleads-php-lib

    ```
2. Follow [Getting started](#getting-started) if you haven't done so.
3. Follow [Setting up your OAuth2 credentials](#setting-up-your-oauth2-credentials)if you haven't set up the credentials yet.
4. You can now use the library.

### Using git clone

[](#using-git-clone)

This method is suitable for those who want to alter or contribute to this library (e.g., submitting pull requests) or wish to try our examples. **All** files in this repository will be downloaded.

1. Run `git clone https://github.com/googleads/googleads-php-lib.git` at the command prompt.
2. You'll get a **googleads-php-lib** directory. Navigate to it by running `cd googleads-php-lib`.
3. Run `composer install` at the command prompt. This will install all dependencies needed for using the library and running examples.
4. Follow [Getting started](#getting-started) if you haven't done so.
5. Follow [Setting up your OAuth2 credentials](#setting-up-your-oauth2-credentials)if you haven't set up the credentials yet.
6. You can now use the library and run any examples you want. Try [GetAllNetworks.php](https://github.com/googleads/googleads-php-lib/blob/HEAD/examples/AdManager/v202211/NetworkService/GetAllNetworks.php)by executing the following command:

    ```
    $ php examples/AdManager/v202211/NetworkService/GetAllNetworks.php

    ```

### Downloading a compressed tarball

[](#downloading-a-compressed-tarball)

This is suitable for those who only want to try out the Ad Manager API with this client library. The extracted directory of the tarball will contain only the `examples/` directory.

1. On the [releases page](https://github.com/googleads/googleads-php-lib/releases), select a version you want to try. Then, under **Download**, select the tarball of your choice. The name of the tarball indicates which product it belongs to, for example, **admanager-examples-vX.Y.Z.tar.gz**.
2. Extract your downloaded file to any location on your computer.
3. Navigate to the extracted directory (for example, **admanager-examples-vX.Y.Z**).
4. Run `composer install` at the command prompt. This will install all dependencies needed for using the library and running examples.
5. Follow [Getting started](#getting-started) if you haven't done so.
6. Follow [Setting up your OAuth2 credentials](#setting-up-your-oauth2-credentials)if you haven't set up the credentials yet.
7. You can now run any examples you want. Try [GetAllNetworks.php](https://github.com/googleads/googleads-php-lib/blob/HEAD/examples/AdManager/v202211/NetworkService/GetAllNetworks.php)by executing the following command:

    ```
    $ php examples/AdManager/v202211/NetworkService/GetAllNetworks.php

    ```

### Setting up your OAuth2 credentials

[](#setting-up-your-oauth2-credentials)

The Ad Manager API uses [OAuth2](https://oauth.net/2/) as the authentication mechanism. Follow the appropriate guide below based on your use case:

- [Using your own credentials](https://github.com/googleads/googleads-php-lib/wiki/API-access-using-own-credentials-(server-to-server-flow))
- [Acting on behalf of clients](https://github.com/googleads/googleads-php-lib/wiki/API-access-on-behalf-of-your-clients-(web-flow))

### Basic usage

[](#basic-usage)

The best way to learn how to use this library is to review the [examples](https://github.com/googleads/googleads-php-lib/blob/HEAD/examples/AdManager).

> All our examples are meant to be run via the command line and not through a webpage.
>
> If you're using 32-bit PHP, you'll need to change all instances of `intval()`to `floatval()` before running an example. This is due to some IDs exceeding the 32-bit `PHP_INT_MAX` that `intval()` changes your value to. In addition, when writing your own code, do *not* apply `intval()` on any attributes that are explicitly an integer.

The following snippet of code from the **GetAllNetworks.php** example gives you an idea of how to use this library.

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

$session = (new AdManagerSessionBuilder())->fromFile()
    ->withOAuth2Credential($oAuth2Credential)
    ->build();

$adManagerServices = new ServiceFactory();

$networkService = $adManagerServices->createNetworkService($session);

$networks = $networkService->getAllNetworks();

// Do something with the $networks.
```

The builder's `fromFile()` method looks for an `adsapi_php.ini` file in your home directory by default. If you want to store this file in another directory, pass the path of the file as an argument. For example:

```
fromFile('/config/myprops.ini')

```

It is highly recommended that you use an `adsapi_php.ini` file. However, if you don't want to or can't use one, you can use the OAuth2 token and ads session builders instead to set the same information. See the builders for details:

- [OAuth2TokenBuilder](https://github.com/googleads/googleads-php-lib/blob/HEAD/src/Google/AdsApi/Common/OAuth2TokenBuilder.php)
- [AdManagerSessionBuilder](https://github.com/googleads/googleads-php-lib/blob/HEAD/src/Google/AdsApi/AdManager/AdManagerSessionBuilder.php)

### WSDL objects with names that are reserved PHP keywords

[](#wsdl-objects-with-names-that-are-reserved-php-keywords)

Some WSDL enum values have names that are reserved PHP keywords and need to be modified when used as PHP constant names. For example, `AND` and `DEFAULT` are generated as `AND_VALUE` and `DEFAULT_VALUE`.

### Logging

[](#logging)

This library conforms to [PSR-3](http://www.php-fig.org/psr/psr-3) for logging and provides the following loggers for Ad Manager:

- SOAP logger
- Report downloader logger

In general, each logger logs a summary and debug message for events (e.g., a SOAP API call). The [level](http://www.php-fig.org/psr/psr-3/#5-psr-log-loglevel) at which messages are logged depends on whether the event succeeded.

Log message \\ Event statusSuccessFailureOne-line summaryINFOWARNINGDebug message (e.g., SOAP payload)DEBUGNOTICE#### Configuring logging

[](#configuring-logging)

By default, each of the library loggers logs to [`STDERR`](http://php.net/manual/en/features.commandline.io-streams.php) on a separate channel using a [Monolog StreamHandler](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/StreamHandler.php).

You can configure some options for these default loggers in the `adsapi_php.ini`file:

```
[LOGGING]
; Optional logging settings.
soapLogFilePath = "path/to/your/soap.log"
soapLogLevel = "NOTICE"
```

If you need to further customize logging, you can specify your own logger entirely by providing a logger that implements [LoggerInterface](https://github.com/php-fig/log/blob/master/Psr/Log/LoggerInterface.php)in the Ad Manager session builder:

```
$session = (new AdManagerSessionBuilder())
    ...
    ->withSoapLogger(new MyCustomSoapLogger())
    ->withReportDownloaderLogger(new MyCustomReportDownloaderLogger())
    ->build();
```

### Utilities

[](#utilities)

We provide some [utilities](//github.com/googleads/googleads-php-lib/wiki/ReportDownloader-Utilities)in this client library for helping you use features in the Ad Manager API more conveniently.

### Reporting

[](#reporting)

When downloading reports, you can set additional [stream context options](http://php.net/manual/en/context.php) using the `stream_context` key to suit your needs (e.g., increasing the timeout as shown below). See also [Guzzle FAQ](http://docs.guzzlephp.org/en/latest/faq.html#how-can-i-add-custom-stream-context-options)for details.

```
$options = [
    'stream_context' => [
        'http' => ['timeout' => 120]
    ]
];
$requestOptionsFactory = new RequestOptionsFactory($session, $options);
$reportDownloader = new ReportDownloader($session, $requestOptionsFactory);
```

### SSL CA files

[](#ssl-ca-files)

PHP automatically sets [`verify_peer`](http://php.net/manual/en/context.ssl.php) to `true` and will do its best to find the most appropriate CA bundle on your system by default. However, not all systems have a known CA bundle on disk (e.g. Windows). This library tries to locate CA bundles on your system by using Guzzle [`default_ca_bundle()`](https://github.com/guzzle/guzzle/blob/6.0.2/src/functions.php#L157).

If this library can't find a CA bundle on your system, you'll get an error message similar to this:

```
cURL error 60: SSL certificate problem: unable to get local issuer certificate.

```

CA file issues can also cause an error like this:

```
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
Couldn't load from
'https://ads.google.com/apis/ads/publisher/v202211/ActivityService?wsdl' :
failed to load external entity
"https://ads.google.com/apis/ads/publisher/v202211/ActivityService?wsdl

```

To remedy, see [Steps for troubleshooting CA file issues](https://github.com/googleads/googleads-php-lib/wiki/Steps-for-troubleshooting-CA-file-issues).

### Documentation

[](#documentation)

PHPDoc for this library can be found in the [gh-pages](https://github.com/googleads/googleads-php-lib/tree/gh-pages) branch of this repository. You can view the Ad Manager API site [here](http://googleads.github.io/googleads-php-lib/AdManager/).

General Ad Manager API documentation can be found on our [Google Developers site](https://developers.google.com/ad-manager).

### Coding Style

[](#coding-style)

We use PSR-2 as a coding style standard. Assuming that you're at the root directory of your project, to check for coding style violations, run

```
vendor/bin/phpcs src --standard=phpcs_ruleset.xml -np

```

To automatically fix (fixable) coding style violations, run

```
vendor/bin/phpcbf src --standard=phpcs_ruleset.xml

```

### Getting support

[](#getting-support)

For client library specific bug reports, feature requests, and patches, create an issue on the [issue tracker](https://github.com/googleads/googleads-php-lib/issues).

For general Ad Manager API questions, bug reports, or feature requests, post to the [Ad Manager API Forum](https://groups.google.com/forum/#!forum/google-doubleclick-for-publishers-api).

### Announcements and updates

[](#announcements-and-updates)

For general Ad Manager API and client library updates and news, you can follow the [Sunset Announcements mailing list](https://groups.google.com/forum/#!forum/dfpapi-sunset-announce)and rely on the [deprecation schedule](https://developers.google.com/ad-manager/docs/deprecation).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance78

Regular maintenance activity

Popularity10

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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 ~25 days

Total

8

Last Release

121d ago

Major Versions

69.0.1 → 70.0.02025-09-08

70.1.1 → 71.0.02026-01-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/66e94ee89dca5cd330f26ae56226bc10d38b18d2de703c751310d67d1a5ab267?d=identicon)[Spirit](/maintainers/Spirit)

---

Top Contributors

[![fiboknacky](https://avatars.githubusercontent.com/u/1702801?v=4)](https://github.com/fiboknacky "fiboknacky (106 commits)")[![thangduo](https://avatars.githubusercontent.com/u/4349155?v=4)](https://github.com/thangduo "thangduo (63 commits)")[![vtsao](https://avatars.githubusercontent.com/u/575559?v=4)](https://github.com/vtsao "vtsao (30 commits)")[![Spirit-act](https://avatars.githubusercontent.com/u/16631523?v=4)](https://github.com/Spirit-act "Spirit-act (19 commits)")[![christopherseeley](https://avatars.githubusercontent.com/u/4163216?v=4)](https://github.com/christopherseeley "christopherseeley (12 commits)")[![api-vtsao](https://avatars.githubusercontent.com/u/16143170?v=4)](https://github.com/api-vtsao "api-vtsao (9 commits)")[![PierrickVoulet](https://avatars.githubusercontent.com/u/6769971?v=4)](https://github.com/PierrickVoulet "PierrickVoulet (9 commits)")[![saturnism](https://avatars.githubusercontent.com/u/1998883?v=4)](https://github.com/saturnism "saturnism (8 commits)")[![shakaran](https://avatars.githubusercontent.com/u/14254?v=4)](https://github.com/shakaran "shakaran (5 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (4 commits)")[![mikeaag](https://avatars.githubusercontent.com/u/1278785?v=4)](https://github.com/mikeaag "mikeaag (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![gitazem](https://avatars.githubusercontent.com/u/7699220?v=4)](https://github.com/gitazem "gitazem (2 commits)")[![jrdnrc](https://avatars.githubusercontent.com/u/1749312?v=4)](https://github.com/jrdnrc "jrdnrc (2 commits)")[![vikash](https://avatars.githubusercontent.com/u/324203?v=4)](https://github.com/vikash "vikash (1 commits)")[![v-noskov](https://avatars.githubusercontent.com/u/17856898?v=4)](https://github.com/v-noskov "v-noskov (1 commits)")[![YOzaz](https://avatars.githubusercontent.com/u/5859318?v=4)](https://github.com/YOzaz "YOzaz (1 commits)")[![dklimkin](https://avatars.githubusercontent.com/u/854377?v=4)](https://github.com/dklimkin "dklimkin (1 commits)")[![Edujugon](https://avatars.githubusercontent.com/u/4853751?v=4)](https://github.com/Edujugon "Edujugon (1 commits)")[![iulyanp](https://avatars.githubusercontent.com/u/6533422?v=4)](https://github.com/iulyanp "iulyanp (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/spirit-act-googleads-php-lib/health.svg)

```
[![Health](https://phpackages.com/badges/spirit-act-googleads-php-lib/health.svg)](https://phpackages.com/packages/spirit-act-googleads-php-lib)
```

###  Alternatives

[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[google/cloud

Google Cloud Client Library

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

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[google/cloud-core

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

343121.4M79](/packages/google-cloud-core)

PHPackages © 2026

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