PHP code example of gulaandrij / google-sheets-bundle
1. Go to this page and download the library: Download gulaandrij/google-sheets-bundle 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/ */
gulaandrij / google-sheets-bundle example snippets
SheetsService::listSheets(): array
SheetsService::listSheetsWithIds(): array
SheetsService::findSheetNameById(int $sheetId): ?string
SheetsClientFactory::listSpreadsheets(): array // global Drive query — lives on the factory, not a bound SheetsService
use Gulaandrij\GoogleSheetsBundle\Attribute\SheetColumn;
final class Allocator
{
#[SheetColumn('Record ID - Contact')]
public ?string $contactId = null;
#[SheetColumn('First Name')]
public ?string $firstName = null;
#[SheetColumn('Email')]
public ?string $email = null;
}
// In your service:
$allocators = $this->allocators->readEntities(Allocator::class);
// returns Allocator[] — the serializer denormalizes each row.
foreach ($this->reports->readAssocIterable(batchSize: 1000) as $row) {
$this->process($row);
}
use Gulaandrij\GoogleSheetsBundle\Test\InMemorySheetsService;
// tests/Functional/AllocatorImportTest.php
protected function setUp(): void
{
parent::setUp();
self::getContainer()->set(
'google_sheets.sheets_service.hubspot_allocators',
new InMemorySheetsService([
'Allocator List' => [
['Record ID - Contact', 'First Name', 'Email'],
['c-1', 'Alice', '[email protected]'],
],
], boundSheet: 'Allocator List'),
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.