PHP code example of brickservers / gsuite

1. Go to this page and download the library: Download brickservers/gsuite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

brickservers / gsuite example snippets


// .env
[email protected]

'credentials_path' => storage_path('credentials.json'),

// .env
GSUITE_DOMAIN=example.com

// Create a new G-Suite account
GSuite::accounts()->create([
    [
        'first_name' => 'John',
        'last_name' => 'Doe',
    ],
    'email' => '[email protected]',
    'default_password' => 'password'
]);

// Get a G-Suite account
GSuite::accounts()->get('[email protected]');

// Get a collection of all G-Suite accounts in your domain
GSuite::accounts()->all();

// Delete a G-Suite account
GSuite::accounts()->delete('[email protected]');

// Suspend a G-Suite account
GSuite::accounts()->suspend('[email protected]');

// Add an alias to a G-Suite account
GSuite::accounts()->alias('[email protected]', '[email protected]');

// Create a new G-Suite group
GSuite::groups()->create('[email protected]', 'Group Name', 'Group description');

// Get a G-Suite group
GSuite::groups()->get('[email protected]');

// Get a collection of all G-Suite groups in your domain
GSuite::groups()->all();

// Delete a G-Suite group
GSuite::groups()->delete('[email protected]');

// Add a member to a G-Suite group
GSuite::groups()->addMember('[email protected]', '[email protected]');

// Flush accounts and groups cache
GSuite::flushCache();

// Flush only accounts cache
GSuite::accounts()->flushCache();

// Flush only groups cache
GSuite::groups()->flushCache();

// Via the CLI
php artisan gsuite:flush-cache

$client = GSuiteServicesClient::getService('orgunit');
bash
php artisan vendor:publish