PHPackages                             brickservers/gsuite - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. brickservers/gsuite

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

brickservers/gsuite
===================

Modern Laravel package for managing Google Workspace (formerly G Suite) with support for Directory API, Classroom, Calendar, Gmail, and Drive APIs

v2.1(1mo ago)23831MITPHPPHP &gt;=8.2CI failing

Since May 26Pushed 1mo agoCompare

[ Source](https://github.com/wallacemyem/gsuite)[ Packagist](https://packagist.org/packages/brickservers/gsuite)[ Docs](https://github.com/wallacemyem/gsuite)[ RSS](/packages/brickservers-gsuite/feed)WikiDiscussions master Synced 5d ago

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

Google Workspace SDK for Laravel
================================

[](#google-workspace-sdk-for-laravel)

[![Latest Version](https://camo.githubusercontent.com/62e6be515b5168a149963dbd4ca94107c970de1728ff7c1118de18f9c703c6b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627269636b736572766572732f6773756974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brickservers/gsuite)[![Total Downloads](https://camo.githubusercontent.com/a4e9b7b779c7e18cbfbfc5d85049f332333621fc34cb74c5c76dad00039c6fdb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f627269636b736572766572732f6773756974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brickservers/gsuite)[![License](https://camo.githubusercontent.com/f305a9808fa86c8d7a111cc9eddfde168b67820647ae533ec0ff17a3ed882d6b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f627269636b736572766572732f6773756974652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A modern, fully-featured Laravel package for managing Google Workspace (formerly G Suite) using the latest Google Admin SDK API. Supports user management, group management, directory operations, and more.

Sponsor
-------

[](#sponsor)

Support the development of this package: [![Sponsor](https://camo.githubusercontent.com/856bf8030a60ef09cec6b0ccacae765ece8eef592b2642a33dcfec11fb623e49/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2545322539442541342d70696e6b3f6c6f676f3d676974687562)](https://github.com/sponsors/wallacemyem)

 [ ![Sponsor with Paystack](https://camo.githubusercontent.com/774a35400cff47003b05c4d389448560e70726aea87cf94cfbb8801d8a610dc4/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f312f31662f506179737461636b2e706e67) ](https://paystack.shop/pay/wallace)

Features
--------

[](#features)

- ✅ **Modern PHP 8.2+** - Uses latest language features (readonly types, enums, named arguments)
- ✅ **User Management** - Create, read, update, delete, suspend, and manage user accounts
- ✅ **Group Management** - Full group CRUD operations and member management
- ✅ **Directory API** - Complete access to the Google Directory API
- ✅ **Type-Safe DTOs** - Data transfer objects for type safety
- ✅ **Comprehensive Error Handling** - Custom exceptions with detailed error information
- ✅ **Logging Support** - Built-in PSR-3 logging for all operations
- ✅ **Fluent Interface** - Simple, clean API for all operations
- ✅ **Laravel 10-13 Support** - Compatible with all modern Laravel versions
- ✅ **Extensible** - Easy to extend with custom services

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.0 or higher
- Google Workspace account with admin access
- Google Cloud Project with Admin SDK API enabled

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

[](#installation)

```
composer require brickservers/gsuite
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="BrickServers\GoogleWorkspace\GoogleWorkspaceServiceProvider" --tag=config
```

This will publish the configuration file to `config/google-workspace.php`.

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

[](#configuration)

### 1. Set Up Google Cloud Project

[](#1-set-up-google-cloud-project)

1. Go to [Google Cloud Console](https://console.cloud.google.com)
2. Create a new project
3. Enable the "Google Admin SDK API"
4. Create a service account
5. Download the credentials JSON file
6. Move the file to `storage/credentials.json` (or configure the path)

### 2. Configure Environment Variables

[](#2-configure-environment-variables)

Add these to your `.env` file:

```
GOOGLE_WORKSPACE_CREDENTIALS_PATH=/path/to/credentials.json
GOOGLE_WORKSPACE_DOMAIN=example.com
GOOGLE_WORKSPACE_SUBJECT=admin@example.com
GOOGLE_WORKSPACE_LOGGING=true
```

### 3. Update Configuration

[](#3-update-configuration)

Edit `config/google-workspace.php` to customize settings:

```
'domain' => env('GOOGLE_WORKSPACE_DOMAIN', 'example.com'),
'credentials_path' => env('GOOGLE_WORKSPACE_CREDENTIALS_PATH', storage_path('credentials.json')),
'subject' => env('GOOGLE_WORKSPACE_SUBJECT'),
'scopes' => [
    'https://www.googleapis.com/auth/admin.directory.user',
    'https://www.googleapis.com/auth/admin.directory.group',
],
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
use BrickServers\GoogleWorkspace\GoogleWorkspace;

// Via facade or service container
$workspace = app('google-workspace');

// Or using dependency injection
public function __construct(GoogleWorkspace $workspace)
{
    $this->workspace = $workspace;
}
```

### User Management

[](#user-management)

#### Create a User

[](#create-a-user)

```
use BrickServers\GoogleWorkspace\DTOs\UserDTO;

$user = new UserDTO(
    email: 'john.doe@example.com',
    givenName: 'John',
    familyName: 'Doe',
    password: 'SecurePassword123!',
    changePasswordAtNextLogin: true,
);

$created = $workspace->users()->create($user);
```

#### Get a User

[](#get-a-user)

```
$user = $workspace->users()->get('john.doe@example.com');

// With projection and view type
use BrickServers\GoogleWorkspace\Enums\UserProjection;
use BrickServers\GoogleWorkspace\Enums\UserViewType;

$user = $workspace->users()->get(
    'john.doe@example.com',
    projection: UserProjection::FULL,
    viewType: UserViewType::ADMIN_VIEW,
);
```

#### List Users

[](#list-users)

```
$result = $workspace->users()->list(maxResults: 100);

$users = $result['users']; // Array of UserDTO
$nextPageToken = $result['nextPageToken']; // For pagination
```

#### Update a User

[](#update-a-user)

```
$updates = new UserDTO(
    email: 'john.doe@example.com',
    givenName: 'Johnny',
    familyName: 'Doe',
);

$updated = $workspace->users()->update('john.doe@example.com', $updates);
```

#### Delete a User

[](#delete-a-user)

```
$workspace->users()->delete('john.doe@example.com');
```

#### Suspend/Unsuspend a User

[](#suspendunsuspend-a-user)

```
// Suspend
$workspace->users()->suspend('john.doe@example.com');

// Unsuspend
$workspace->users()->unsuspend('john.doe@example.com');
```

#### Manage User Aliases

[](#manage-user-aliases)

```
// Add alias
$workspace->users()->addAlias('john.doe@example.com', 'j.doe@example.com');

// Remove alias
$workspace->users()->removeAlias('john.doe@example.com', 'j.doe@example.com');
```

### Group Management

[](#group-management)

#### Create a Group

[](#create-a-group)

```
use BrickServers\GoogleWorkspace\DTOs\GroupDTO;

$group = new GroupDTO(
    email: 'developers@example.com',
    name: 'Development Team',
    description: 'All developers in the organization',
);

$created = $workspace->groups()->create($group);
```

#### Get a Group

[](#get-a-group)

```
$group = $workspace->groups()->get('developers@example.com');
```

#### List Groups

[](#list-groups)

```
$result = $workspace->groups()->list(maxResults: 100);

$groups = $result['groups']; // Array of GroupDTO
$nextPageToken = $result['nextPageToken']; // For pagination
```

#### Update a Group

[](#update-a-group)

```
$updates = new GroupDTO(
    email: 'developers@example.com',
    name: 'Dev Team',
    description: 'Updated description',
);

$updated = $workspace->groups()->update('developers@example.com', $updates);
```

#### Delete a Group

[](#delete-a-group)

```
$workspace->groups()->delete('developers@example.com');
```

#### Manage Group Members

[](#manage-group-members)

```
// Add member
$workspace->groups()->addMember('developers@example.com', 'john.doe@example.com');

// Remove member
$workspace->groups()->removeMember('developers@example.com', 'john.doe@example.com');
```

Error Handling
--------------

[](#error-handling)

The package throws `GoogleWorkspaceException` for all API errors:

```
use BrickServers\GoogleWorkspace\Exceptions\GoogleWorkspaceException;

try {
    $workspace->users()->create($user);
} catch (GoogleWorkspaceException $e) {
    // Handle specific errors
    if ($e->getCode() === 5) {
        // Resource not found
    }

    logger()->error('Google Workspace API error: ' . $e->getMessage());
}
```

### Exception Types

[](#exception-types)

- `GoogleWorkspaceException::validationError()` - Validation failed
- `GoogleWorkspaceException::resourceNotFound()` - Resource doesn't exist
- `GoogleWorkspaceException::undeletableResource()` - Protected resource
- `GoogleWorkspaceException::apiError()` - General API error
- `GoogleWorkspaceException::accessDenied()` - Insufficient permissions
- `GoogleWorkspaceException::missingCredentials()` - Credentials not configured

Data Transfer Objects (DTOs)
----------------------------

[](#data-transfer-objects-dtos)

### UserDTO

[](#userdto)

```
new UserDTO(
    email: string,
    givenName: string,
    familyName: string,
    password: ?string = null,
    changePasswordAtNextLogin: bool = true,
    suspended: bool = false,
    phone: ?string = null,
    title: ?string = null,
    customSchemas: ?array = null,
)
```

### GroupDTO

[](#groupdto)

```
new GroupDTO(
    email: string,
    name: ?string = null,
    description: ?string = null,
)
```

Enums
-----

[](#enums)

### UserProjection

[](#userprojection)

```
UserProjection::BASIC    // Basic information only
UserProjection::FULL     // Full user information
UserProjection::CUSTOM   // Custom schema information
```

### UserViewType

[](#userviewtype)

```
UserViewType::ADMIN_VIEW      // Admin perspective
UserViewType::DOMAIN_PUBLIC   // Public domain view
```

### ApiScope

[](#apiscope)

Predefined OAuth scopes for different APIs:

```
ApiScope::DIRECTORY_USER
ApiScope::DIRECTORY_GROUP
ApiScope::CLASSROOM_COURSES
ApiScope::CALENDAR
ApiScope::GMAIL_COMPOSE
ApiScope::DRIVE
// ... and more
```

Migration from Old Package
--------------------------

[](#migration-from-old-package)

If you're upgrading from `wyattcast44/gsuite` or `brickservers/gsuite`:

### Changes Summary

[](#changes-summary)

1. **Namespace Changed**: `Wyattcast44\GSuite` → `BrickServers\GoogleWorkspace`
2. **New DTOs**: Use `UserDTO` and `GroupDTO` instead of raw arrays
3. **Type-Safe**: All methods now have proper type hints
4. **Better Errors**: Custom exception types for better error handling
5. **Modern PHP**: Uses PHP 8.2+ features (enums, readonly types, named arguments)

### Migration Steps

[](#migration-steps)

#### Before (Old Package)

[](#before-old-package)

```
GSuite::accounts()->create([
    ['first_name' => 'John', 'last_name' => 'Doe'],
    'email' => 'john.doe@example.com',
    'default_password' => 'password'
]);
```

#### After (New Package)

[](#after-new-package)

```
use BrickServers\GoogleWorkspace\DTOs\UserDTO;

$user = new UserDTO(
    email: 'john.doe@example.com',
    givenName: 'John',
    familyName: 'Doe',
    password: 'password',
);

app('google-workspace')->users()->create($user);
```

Testing
-------

[](#testing)

```
composer test
```

Run with coverage:

```
composer test-coverage
```

Debugging
---------

[](#debugging)

Enable logging in your `.env`:

```
GOOGLE_WORKSPACE_LOGGING=true
```

View logs in `storage/logs/laravel.log` to see all API operations.

Supported APIs
--------------

[](#supported-apis)

- ✅ Google Admin Directory API
- ✅ Google Classroom API (ready)
- ✅ Google Calendar API (ready)
- ✅ Google Gmail API (ready)
- ✅ Google Drive API (ready)

Security Best Practices
-----------------------

[](#security-best-practices)

1. **Never commit credentials.json** - Add to `.gitignore`
2. **Use environment variables** - Store sensitive data in `.env`
3. **Limit API scopes** - Only request scopes your app needs
4. **Enable logging** - Monitor all API operations
5. **Use protected resources** - Add critical accounts/groups to `undeletable` list
6. **Validate input** - DTOs provide validation out of the box

Performance Tips
----------------

[](#performance-tips)

1. **Use pagination** - Always set `maxResults` parameter
2. **Cache results** - Store frequently accessed data
3. **Batch operations** - Group multiple API calls when possible
4. **Enable logging selectively** - Disable in production if not needed

Contributing
------------

[](#contributing)

Contributions are welcome! Please follow Laravel coding standards and include tests.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for version history and breaking changes.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Support
-------

[](#support)

For issues, questions, or suggestions, please open an issue on [GitHub](https://github.com/wallacemyem/gsuite).

Credits
-------

[](#credits)

- Modern rewrite by [BrickServers Team](https://brickng.com)
- Original package by [Wyatt Cast](https://github.com/WyattCast44/gsuite)
- Built with the [Google Admin SDK](https://developers.google.com/admin-sdk)

###  Health Score

50

↑

FairBetter than 96% of packages

Maintenance90

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 84.1% 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 ~710 days

Total

4

Last Release

49d ago

Major Versions

0.0.1 → v1.12020-05-26

v1.1 → 2.02026-03-27

PHP version history (2 changes)0.0.1PHP ^7.1

2.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3cbf2e4cfd63a6fd6d6ec7a503a022d46ad6b94ee11c329f93203cc855ba61cd?d=identicon)[wallacemyem](/maintainers/wallacemyem)

---

Top Contributors

[![WyattCast44](https://avatars.githubusercontent.com/u/17957937?v=4)](https://github.com/WyattCast44 "WyattCast44 (132 commits)")[![wallacemyem](https://avatars.githubusercontent.com/u/32508088?v=4)](https://github.com/wallacemyem "wallacemyem (24 commits)")[![felabrecque](https://avatars.githubusercontent.com/u/165329484?v=4)](https://github.com/felabrecque "felabrecque (1 commits)")

---

Tags

laravelgsuiteGmail APIbrickserversgoogle-workspaceadmin-sdkdirectory-apiclassroom-apicalendar-apidrive-api

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/brickservers-gsuite/health.svg)

```
[![Health](https://phpackages.com/badges/brickservers-gsuite/health.svg)](https://phpackages.com/packages/brickservers-gsuite)
```

###  Alternatives

[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[tonysm/importmap-laravel

Use ESM with importmap to manage modern JavaScript in Laravel without transpiling or bundling.

148399.8k1](/packages/tonysm-importmap-laravel)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)

PHPackages © 2026

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