PHPackages                             bscheshirwork/yii2-google-api-client-sa - 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. bscheshirwork/yii2-google-api-client-sa

ActiveYii2-extension[API Development](/categories/api)

bscheshirwork/yii2-google-api-client-sa
=======================================

A Yii2 wrapper for the official Google API PHP Client (In case used Service Account + DwD)

023PHP

Since Jul 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/bscheshirwork/yii2-google-api-client-sa)[ Packagist](https://packagist.org/packages/bscheshirwork/yii2-google-api-client-sa)[ RSS](/packages/bscheshirwork-yii2-google-api-client-sa/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

A Yii2 wrapper for the official Google API PHP Client (In case used Service Account + DwD)
------------------------------------------------------------------------------------------

[](#a-yii2-wrapper-for-the-official-google-api-php-client-in-case-used-service-account--dwd)

For easily config and give you access to the service

Installation
------------

[](#installation)

First you can register Google service account with DwD, user for this account and enable G suite access for this user id. [api-client-library service-accounts](https://developers.google.com/api-client-library/php/auth/service-accounts)

Second - install wrapper and configure it use secret data.

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Add

```
"bscheshirwork/yii2-google-api-client-sa": "*"

```

to the require section of your `composer.json` file.

This package will also install the [google/apiclient](http://github.com/google/apiclient) library.

Configuration
-------------

[](#configuration)

You application may use as much Google\_Service instances as you need, by adding an entry into the `components` index of the Yii configuration array.

Here's how to setup GMail for example, a usage sample is provided below.

```
    'components' => [
        // ..
        'gmail' => [
            'class' => 'bscheshirwork\gacsa\GoogleApiClient',
            'googleApplicationCredentials' => '@runtime/secret-place/myprojectname-privatekeyshortdigits.json',
            'api' => Google_Service_Gmail::class,
        ],
```

This will enable you to access the GMail authenticated service `Yii::$app->gmail->getService()` in your application.

Usage
-----

[](#usage)

**Displaying your newest message subject on GMail**

```
/**
 * @var $service Google_Service_Gmail
 */
$service = Yii::$app->gmail->getService(function(){
    $userToImpersonate = 'email@suitedomain.com';
    /** @var \Google_Client $client */
    $client->setSubject($userToImpersonate);
    return $client;
});

$messages = $service->users_messages->listUsersMessages('me', [
    'maxResults' => 1,
    'labelIds' => 'INBOX',
]);
$list = $messages->getMessages();

if (count($list) == 0) {
    echo "You have no emails in your INBOX .. how did you achieve that ??";
} else {
    $messageId = $list[0]->getId(); // Grab first Message

    $message = $service->users_messages->get('me', $messageId, ['format' => 'full']);

    $messagePayload = $message->getPayload();
    $headers = $messagePayload->getHeaders();

    echo "Your last email subject is: ";
    foreach ($headers as $header) {
        if ($header->name == 'Subject') {
            echo "" . $header->value . "";
        }
    }

}
```

Thanks [Mehdi Achour](https://github.com/machour/yii2-google-apiclient)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5769211?v=4)[bscheshirwork](/maintainers/bscheshirwork)[@bscheshirwork](https://github.com/bscheshirwork)

---

Top Contributors

[![bscheshirwork](https://avatars.githubusercontent.com/u/5769211?v=4)](https://github.com/bscheshirwork "bscheshirwork (4 commits)")

### Embed Badge

![Health badge](/badges/bscheshirwork-yii2-google-api-client-sa/health.svg)

```
[![Health](https://phpackages.com/badges/bscheshirwork-yii2-google-api-client-sa/health.svg)](https://phpackages.com/packages/bscheshirwork-yii2-google-api-client-sa)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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