Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Cloud Spanner

Cloud Spanner Laravel Package

google/cloud-spanner

Idiomatic PHP client for Google Cloud Spanner, a fully managed relational database with global transactional consistency, ANSI SQL, schemas, and automatic synchronous replication. Install via Composer; requires the gRPC extension and Google Cloud authentication.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Cloud Spanner
How do I install google/cloud-spanner in a Laravel app?
Install it with Composer using composer require google/cloud-spanner. The package requires the PHP gRPC extension, so install and enable that extension on your host or in your Docker image. Then configure Google Cloud authentication using Application Default Credentials or a service account. In Laravel, keep SpannerClient creation in a service provider or dedicated service class.
Can I use Laravel Eloquent and migrations with Google Cloud Spanner?
Not directly. Spanner does not map cleanly to Eloquent's active-record conventions, so plan on raw SQL, a repository layer, or a custom adapter. Laravel's Schema Builder cannot manage Spanner schemas; use Spanner DDL through raw queries or a custom Artisan command or migration tool.
Which Laravel and PHP versions are supported by google/cloud-spanner?
The package is a framework-agnostic Google Cloud PHP client, so it is not tied to a specific Laravel release. Your Laravel version must run on a PHP version allowed by the package's Composer constraints, and the gRPC extension must be available. Check the current google/cloud-spanner requirements on Packagist before pinning versions.
Is Cloud Spanner a good alternative to MySQL or PostgreSQL for Laravel?
Only when you specifically need globally distributed, strongly consistent transactions, automatic multi-region replication, and horizontal scale. It is usually a poor fit for lightweight or read-heavy Laravel apps because cost and operational overhead are hard to justify. For standard CRUD apps, MySQL or PostgreSQL with Laravel's native ORM is simpler.
How do I authenticate google/cloud-spanner in Laravel on Forge, Vapor, or GKE?
Use Google Cloud Application Default Credentials where possible. On GCP services such as GKE, the metadata server can provide credentials automatically. Outside GCP, provide a service account key through secure secret management and GOOGLE_APPLICATION_CREDENTIALS, and never commit credentials to your repository.
Why does google/cloud-spanner require the gRPC extension?
The PHP client uses gRPC to communicate with Cloud Spanner. You must install and enable the grpc PHP extension in every environment, including local development, CI, and production images. Bake it into Docker builds and verify it is loaded before deploying Laravel.
How does session caching work with Spanner multiplexed sessions?
The V2 Spanner client uses multiplexed sessions so many concurrent requests can share a single session, reducing backend resource consumption and session cleanup overhead. Session caching defaults to a PSR-6 compatible SysvCacheItemPool. You can configure a PSR-6 cache implementation appropriate for your Laravel deployment.
What are the main production risks of using Cloud Spanner with Laravel?
Watch for gRPC installation gaps, Spanner SQL dialect differences, cost and capacity management, and the lack of native Eloquent and Schema Builder support. Keep Spanner access behind interfaces, monitor CPU and node usage, and test retry and mutation behavior. Pin google/cloud-spanner to v2.11.3 or later for mutation-heavy workloads.
Does google/cloud-spanner support precommit-token commit retries and buffered mutations?
Yes, the client supports buffered mutations and commit retries, including precommit tokens. Version 2.11.3 is a patch-level correctness fix that improves write-path reliability during retries. Pin to at least v2.11.3 and test that buffered mutations are cleared correctly on retry.
How should I test a Laravel application that uses google/cloud-spanner?
Keep Spanner access behind an interface or repository so most application logic can be unit tested with fakes. Run integration tests against a dedicated Spanner test instance or database to validate SQL dialect, DDL, and commit behavior. Specifically test retry paths, precommit-token handling, and mutation buffering if your app uses them.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager