kunstmaan/google-api-custom
Laravel/PHP wrapper for Google APIs with custom configuration support. Helps integrate Google services (e.g., analytics or other endpoints) using a simplified client setup, credential handling, and service initialization geared toward app-specific needs.
google/apiclient, eliminating repetitive boilerplate (e.g., OAuth2 flows, service initialization) while preserving flexibility for custom logic.local, staging, prod) via Laravel’s config system, critical for SaaS or enterprise apps.spatie/fractal).ServiceProvider lifecycle, enabling dependency injection and singleton reuse. Minimal risk if following Laravel conventions.config/google-api-custom.php, reducing hardcoded secrets. Supports .env overrides for environment-specific values.Google::service('Drive')->files()->list()), improving readability and reducing coupling.app() helper). Verify via:
ServiceProvider for binding names.array vs. list).implode signature changes).composer.json constraint (e.g., php: ^8.1) and run static analysis (e.g., phpstan).google/apiclient (v2.x). Ensure alignment with your project’s requirements:
Google_Service_Drive).google/apiclient may break compatibility. Monitor for v3.x releases.boot() methods).config['auth_strategy']).array_key_first deprecations).Authentication Strategy:
.env (e.g., GOOGLE_CREDENTIALS_JSON).Service Scope:
GoogleDriveClient and expand to GoogleCalendarClient later.Error Handling:
GoogleApiException).App\Exceptions\Handler.try {
$files = Google::service('Drive')->files()->list();
} catch (Google_Service_Exception $e) {
Log::error("Google API error: {$e->getMessage()}", ['code' => $e->getCode()]);
throw new GoogleApiException($e->getMessage(), $e->getCode());
}
Testing Strategy:
Google_Client and verify config loading.vcrphp) or Mockery to simulate API responses.public function test_list_files_returns_expected_structure() {
$mockResponse = ['files' => [['id' => '123']]];
$this->mockGoogleService('Drive', 'files', 'list', $mockResponse);
$files = Google::service('Drive')->files()->list();
$this->assertEquals('123', $files->getFiles()[0]->id);
}
Performance:
singleton() binding for stateless operations; avoid for stateful ones (e.g., caching).Monitoring:
Log::channel('google') for structured logging.Google::setLogger(function ($message) {
Log::channel('google')->info($message);
});
Scaling:
guzzlehttp/ringphp).spatie/laravel-caching).$client->setRetryConfig([
'max_retries' => 3,
'backoff_factor' => 2,
]);
config() helper for environment-specific settings (e.g., credentials, scopes).Google::service('Drive')), improving readability and reducing boilerplate.php artisan google:auth).composer.json to:
array_merge in PHP 9.0).phpstan, psalm) to catch compatibility issues early.google/apiclient (v2.x). Ensure version alignment with your project’s requirements:
Google_Service_Drive).google/apiclient may introduce breaking changes. Monitor for v3.x releases.$file = Google::service('Drive')->files()->get('fileId');
return new GoogleDriveFile([
'name' => $file->getName(),
'id' => $file->getId(),
]);
composer require kunstmaan/google-api-custom
google/apiclient version).How can I help you explore Laravel packages today?