PHP code example of resgen / lumen-gcp

1. Go to this page and download the library: Download resgen/lumen-gcp 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/ */

    

resgen / lumen-gcp example snippets


use Google\Cloud\Storage\StorageClient;
use Resgen\Common\Gcp\GoogleServiceAccountProvider;
use Resgen\Common\Gcp\GoogleServiceAccount;

// omitting Lumen app init...follow their examples

// Register service account in your app
$app->register(GoogleServiceAccountProvider::class);

// Example GCP Storage client usage
$gcpStorageClient = new StorageClient([
    'keyFilePath' => app(GoogleServiceAccount::class)->getFilePath()
]);


use Google\Cloud\Storage\StorageClient;
use Resgen\Common\Gcp\GoogleServiceAccountProvider;
use Resgen\Common\Gcp\GoogleServiceAccountBundle;

// omitting Lumen app init...follow their examples

// Register service account in your app
$app->register(GoogleServiceAccountProvider::class);

$gcpAccountBundle = app(GoogleServiceAccountBundle::class);

// Example GCP Storage client usage
$storageAccountOne = new StorageClient([
    'keyFilePath' => $gcpAccountBundle->get('GCP_ACCOUNT_ONE')->getFilePath()
]);

$storageAccountTwo = new StorageClient([
    'keyFilePath' => $gcpAccountBundle->get('GCP_ACCOUNT_TWO')->getFilePath()
]);

$storageAccountThree = new StorageClient([
    'keyFilePath' => $gcpAccountBundle->get('GCP_ACCOUNT_THREE')->getFilePath()
]);