google/cloud-spanner
Idiomatic PHP client for Google Cloud Spanner, a globally consistent relational database. Install via Composer and use gRPC to connect to instances/databases, run SQL queries with parameters, and benefit from V2 multiplexed sessions for efficient concurrent requests.
Adopt if:
spanner-emulator).Look elsewhere if:
RETURNING, complex CTEs). Use Cloud SQL Proxy as a stopgap."This package lets us leverage Google Cloud Spanner—a globally distributed SQL database—directly from our PHP/Laravel stack. It eliminates the complexity of managing multi-region databases while guaranteeing strong consistency for critical transactions (e.g., payments, inventory). By adopting Spanner, we reduce operational overhead, improve disaster recovery, and future-proof our architecture for global scale. The Apache 2.0 license and Google’s GA support ensure long-term reliability."
Key Outcomes:
*"The google/cloud-spanner PHP package provides a production-ready, idiomatic client for Cloud Spanner with key advantages:
JOIN, GROUP BY) plus Spanner-specific features like transactional DML.Trade-offs:
Quick Start:
$spanner = new SpannerClient(['cacheItemPool' => new FilesystemAdapter()]);
$db = $spanner->instance('my-instance')->database('my-db');
$user = $db->execute('SELECT * FROM Users WHERE id = @id', ['parameters' => ['id' => 123]])->rows()->current();
Next Steps:
ALTER TABLE with zero downtime)."*How can I help you explore Laravel packages today?