joelbutcher/laravel-googleads

Laravel Service Provider for the Google Ads Client OAuth2 Wrapper

v9.0.0 2024-10-09 16:42 UTC

README

Total Downloads Latest Stable Version License

A Laravel wrapper for the Google Ads Api Client OAuth2 Wrapper.

Installation

Install the package via composer:

composer require joelbutcher/laravel-googleads

Add the service provider to your package service providers in config/app.php:

/*
* Package Service Providers...
*/
\JoelButcher\LaravelGoogleAds\ServiceProvider::class,

Then publish the config file:

php artisan vendor:publish --provider="JoelButcher\LaravelGoogleAds\ServiceProvider"

Update your services.php config file with the following

<?php

return [
    'google' => [
        'client_id' => env('GOOGLE_CLIENT_ID'),
        'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    ],
    
    'google_ads' => [
        'developer_token' => env('GOOGLE_ADS_DEVELOPER_TOKEN'),
        'sdk_version' => env('GOOGLE_ADS_VERSION'),
    ],
];

Usage

To use the Google Ads Service, you may inject the service into the constructor of your class, like below:

<?php

use JoelButcher\GoogleAds\GoogleAds;

class MyClass
{
    public function __construct(private GoogleAds $googleAds) {}
}

You may then call any of the methods found on the wrapped Google Ads Client

// As yourself
$this->googleAds->authorize($refreshToken);

// As an MCC on behalf of a managed customer
$this->googleAds->authorize($refreshToken, $customerId);

// Campaign Service
$service = $this->googleAds->getCampaignServiceClient();

Versioning

PHP supported version: ^8.0

Google Ads PHP SDK versions: ^19.0 (V12, V13)

Maintainers

Developed and maintained by Joel Butcher

Credits

You can view all contributors here

License

This package is open-sourced software licensed under the MIT license.