PHPackages                             tguruslan/yii2-google-apiclient - 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. tguruslan/yii2-google-apiclient

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

tguruslan/yii2-google-apiclient
===============================

A Yii2 wrapper for the official Google API 2 PHP Client

1.2.2(3y ago)23MITPHP

Since Aug 31Pushed 3y agoCompare

[ Source](https://github.com/tguruslan/yii2-google-apiclient)[ Packagist](https://packagist.org/packages/tguruslan/yii2-google-apiclient)[ Docs](https://github.com/tguruslan/yii2-google-apiclient)[ RSS](/packages/tguruslan-yii2-google-apiclient/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

yii2-google-apiclient
=====================

[](#yii2-google-apiclient)

A Yii2 wrapper for the official Google API PHP Client.

[![Latest Stable Version](https://camo.githubusercontent.com/89efc885e3433662c8cd7a4db8bf3b8f3fad684f49f1fa91a2e38f463b24322c/68747470733a2f2f706f7365722e707567782e6f72672f7467757275736c616e2f796969322d676f6f676c652d617069636c69656e742f76657273696f6e)](https://packagist.org/packages/tguruslan/yii2-google-apiclient)[![Latest Unstable Version](https://camo.githubusercontent.com/8ccdc8b571fd08c06578f8ec1120447fc5b2c75513e4b9f8a01e8fa989935308/68747470733a2f2f706f7365722e707567782e6f72672f7467757275736c616e2f796969322d676f6f676c652d617069636c69656e742f762f756e737461626c65)](//packagist.org/packages/tguruslan/yii2-google-apiclient)[![License](https://camo.githubusercontent.com/51d98855043332c792944425e000e663711cf450028e30623ddfba2a4f570c2f/68747470733a2f2f706f7365722e707567782e6f72672f7467757275736c616e2f796969322d676f6f676c652d617069636c69656e742f6c6963656e7365)](https://packagist.org/packages/tguruslan/yii2-google-apiclient)[![Total Downloads](https://camo.githubusercontent.com/62359963fef96fb74b1c34d98f211ca015c0c52b09a83c6e26f4fa00f0a9a020/68747470733a2f2f706f7365722e707567782e6f72672f7467757275736c616e2f796969322d676f6f676c652d617069636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/tguruslan/yii2-google-apiclient)

This extension comes with:

- A console utility to generate your credentials files
- A component that will take care of the authentication, and give you access to the service

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

[](#installation)

The preferred method of installation is via [Packagist](https://packagist.org) and [Composer](https://getcomposer.org/download/). Run the following command to install the package and add it as a requirement to your project's `composer.json`:

```
composer require tguruslan/yii2-google-apiclient
```

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

[](#configuration)

**Credentials file**

In order to use this extension, you will be needing a credentials file for your Google Application.

You can generate this file using the provided console utility:

- Configure the module in `config/console.php`:

```
'bootstrap' => ['log', 'yii2gac'],
'modules' => [
    'yii2gac' => [
        'class' => 'tguruslan\yii2\google\apiclient\Module',
    ],
],
```

- Use the /configure sub command:

```
./yii yii2gac/configure  [api] # replace [api] with api sections separated by comma, for example: admin,groupssettings
```

- If api has several versions type version or press Enter
- If need pick the desired version number type one of variants
- When need enter required scopes paste full scopes url separated by a comma

where `clientSecretPath` is the path to your secret JSON file obtained from the [Google Console](https://console.developers.google.com/) and `api` the api identifier (it will be prompted for if not provided).

**Components**

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' => [
        // ..
        'google' => [
            'class' => 'tguruslan\yii2\google\apiclient\components\GoogleApiClient',
            'credentialsPath' => '@runtime/google-apiclient/auth.json',
            'clientSecretPath' => '@runtime/google-apiclient/secret.json',
        ],
```

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

Sample usage
------------

[](#sample-usage)

**Displaying your newest message subject on GMail**

```
$gmail = new \Google_Service_Gmail(Yii::$app->google->getService());

$messages = $gmail->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 = $gmail->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 . "";
        }
    }

}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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.

###  Release Activity

Cadence

Every ~101 days

Total

5

Last Release

1308d ago

### Community

Maintainers

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

---

Top Contributors

[![machour](https://avatars.githubusercontent.com/u/304450?v=4)](https://github.com/machour "machour (9 commits)")[![tguruslan](https://avatars.githubusercontent.com/u/17878352?v=4)](https://github.com/tguruslan "tguruslan (4 commits)")[![tguruslan-art](https://avatars.githubusercontent.com/u/244917149?v=4)](https://github.com/tguruslan-art "tguruslan-art (2 commits)")

---

Tags

apigoogleyii2

### Embed Badge

![Health badge](/badges/tguruslan-yii2-google-apiclient/health.svg)

```
[![Health](https://phpackages.com/badges/tguruslan-yii2-google-apiclient/health.svg)](https://phpackages.com/packages/tguruslan-yii2-google-apiclient)
```

###  Alternatives

[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1243.1k1](/packages/skeeks-yii2-google-api)[dotzero/yii2-amocrm

Расширение для Yii Framework 2 реализующее клиент для работы с API amoCRM

1639.7k](/packages/dotzero-yii2-amocrm)

PHPackages © 2026

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