google/cloud-core
Core infrastructure library for Google Cloud PHP clients. Provides shared components like authentication, retries, request handling, and utilities used across Google Cloud service packages. Not intended for direct use; typically installed as a dependency.
Google\Cloud\Core\ServiceBuilder) and configuration management (supports .env for credentials). The GA (Generally Available) status ensures stability for production use.composer require google/cloud-core and initialize services via Google\Cloud\Core\ServiceBuilder.google/cloud-storage, google/cloud-bigquery) rely on it..env conventions.keyFile/keyFilePath options are marked obsolete (use Google\Auth\Credentials instead), which may require updates to legacy Laravel integrations.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Breaking Changes | Minor risks from v2 promotions (e.g., Logging, Trace) in recent releases. | Use semantic versioning (^1.72.0) and test against Laravel’s PHP 8.3+ stack. |
| PHP Version Support | Officially supports PHP 8.1–8.4; Laravel 10+ uses PHP 8.2/8.3. | Pin to ^1.72.0 to avoid PHP 8.4-only deprecations. |
| Performance Overhead | Minimal; core utilities are lazy-loaded (e.g., retries, validation). | Benchmark in Laravel’s request lifecycle (e.g., middleware vs. service initialization). |
| Emulator Dependency | Some features (e.g., Datastore V2) require gRPC emulators for local dev. | Document Docker-based emulator setup in Laravel’s docker-compose.yml. |
Authentication Strategy:
ServiceBuilder configuration.putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json') vs. Google\Cloud\Core\ServiceBuilder::withCredentials().Retry Policy Customization:
Google\Cloud\Core\Retry\RetrySettings in a Laravel service provider.Multi-Service Orchestration:
ServiceBuilder instances can optimize credential reuse.$builder = new Google\Cloud\Core\ServiceBuilder();
$storage = $builder->buildStorageClient();
$bigquery = $builder->buildBigQueryClient();
Local Development:
.env:
GOOGLE_CLOUD_PROJECT=my-project
FIRESTORE_EMULATOR_HOST=localhost:8080
Monitoring and Observability:
Google\Cloud\Logging\LoggingClient (built on this core) with OpenTelemetry.Google\Cloud\Core\ServiceBuilder as a singleton..env via Laravel’s config() helper.grpc, protobuf (for gRPC-based services like Datastore, Firestore).ext-curl (fallback for non-gRPC services).| Phase | Action | Laravel Integration Point |
|---|---|---|
| Assessment | Audit existing Google Cloud integrations (custom vs. official SDK). | Review config/google.php, service providers. |
| Dependency Update | Replace custom auth/retry logic with google/cloud-core. |
Migrate to ServiceBuilder in AppServiceProvider. |
| Configuration | Centralize credentials in .env and Laravel config. |
Use env('GOOGLE_APPLICATION_CREDENTIALS'). |
| Testing | Validate retries, validation, and emulator support in Laravel’s test suite. | Add GoogleCloudTestCase to phpunit.xml. |
| Deployment | Update composer.json and deploy with zero downtime (core is backward-compatible). |
Use composer require google/cloud-core:^1.72.0. |
spatie/google-cloud-storage can coexist but may duplicate auth logic.Phase 1: Core Integration (2–4 weeks)
ServiceBuilder.config/google.php to use Laravel’s .env for credentials.ServiceBuilder singleton and credential management.Phase 2: Service-Specific Adoption (1–2 weeks per service)
google/cloud-storage).Storage facade with Google\Cloud\Storage\StorageClient.BigQueryServiceProvider).Phase 3: Observability (1 week)
Google\Cloud\Logging\LoggingClient to Laravel’s logging stack.Phase 4: Local Dev Optimization (1 week)
docker-compose.yml and .env.services:
firestore-emulator:
image: google/cloud-sdk
command: gcloud beta emulators firestore start --host-port=0.0.0.0:8080
^1.72.0 for PHP 8.3).composer normalize to lock versions of google/cloud-* packages."require": {
"google/cloud-core": "^1.72.0",
"google/cloud-storage": "^1.30.0"
}
keyFileHow can I help you explore Laravel packages today?