google/cloud-pubsub
Idiomatic PHP client for Google Cloud Pub/Sub, a fully-managed real-time messaging service for sending and receiving messages between independent applications. Install via Composer; supports REST and gRPC with built-in authentication helpers.
Architecture fit
google/cloud-pubsub is a vendor SDK, not a Laravel package. It ships no ServiceProvider, facade, config stub, or publishable assets. Everything — client construction, credential resolution, topic/subscription naming, worker lifecycle — becomes application code your team owns.Illuminate\Contracts\Queue\Queue (push, pop, later, delete, release). Pub/Sub's model — push subscriptions to HTTP endpoints, or pull/streaming-pull with explicit ack deadlines — does not map cleanly onto that contract. You either write a custom queue driver (moderate complexity, ongoing maintenance) or bypass the queue contract and treat Pub/Sub as an event bus with dedicated consumers.grpc PHP extension, blocking I/O, careful lease management, and a worker process model that diverges from queue:work.PublisherClient, GetTopicRequest, proto messages). The library also exposes a simpler hand-written Google\Cloud\PubSub\PubSub / Topic / Subscription API. Pick one and standardize — mixing them across a codebase is a common source of confusion.Integration feasibility
composer require google/cloud-pubsub. No framework version constraints, no conflicts with Laravel's dependency tree in practice (it pulls google/gax, google/protobuf, google/common-protos, grpc/grpc if present).keyFile / keyFilePath options were deprecated in v2.15.0. On GKE/Cloud Run this is fine (Workload Identity). Off-GCP — a Laravel app on Laravel Forge, Ploi, or a colo box — you must either mount a service-account JSON and set GOOGLE_APPLICATION_CREDENTIALS or configure Workload Identity Federation. That is a secrets-management decision, not a code decision, and it should be made before the first commit.config/queue.php connection, no Horizon support, no queue:failed visibility out of the box. If operations expect the standard Laravel queue tooling, that expectation must be reset early.Technical risk
google-cloud-php monorepo, not a standalone project. Real-world usage flows through the monorepo. Do not read the low score as abandonment — but equally, do not read it as community validation within Laravel, because there is none. You will be the first team in your Slack to hit any integration edge case.Key questions
acme/laravel-pubsub) wrapping the SDK with config, service provider, and a typed publish API? This is the single highest-leverage decision for maintainability.Stack fit
PubSubServiceProvider binding a singleton PubSub client, a config file for project ID and credential path, and a small typed wrapper around Topic::publish() covers 90% of publishing needs. Publishing from HTTP requests is fast and non-blocking enough for typical Laravel request budgets; for latency-sensitive paths, publish via a queued job.Route::post('/pubsub/handler', ...) → verify the OIDC JWT from the Authorization: Bearer header against Google's public keys → dispatch to a Laravel job → return 2xx. Pub/Sub retries non-2xx automatically, which gives you retry semantics almost for free. This is the most Laravel-native shape and should be the default architecture.Subscription::pull() or the streaming puller, run under Supervisor. Treat it as a separate deployable concern from queue:work — different restart policy, different memory ceiling, different scaling metric (subscription backlog, not queue depth).maxDeliveryAttempts on the subscription rather than relying on Laravel's failed_jobs. This is a Pub/Sub-native control that Laravel's tooling does not expose.Migration path
EventPublisher), keeping the existing queue driver live. Dual-write or shadow-publish; verify message shape and volume.google/cloud-pubsub V1: the library ships a MIGRATING.md; the V1→V2 move is largely mechanical (client class renames, proto message objects replacing arrays). Budget a half-day per integration surface plus a full regression pass — argument-shape changes fail at runtime, not compile time.Compatibility
grpc PHP extension. It is optional for REST transport and required for streaming pull. If your build images are managed (Laravel Vapor, Forge, container base images), confirm the extension can be installed before committing to a pull architecture. Vapor in particular is a poor fit for long-running pullers.PubSub client is generally safe to hold across requests, but gRPC channel state under a forked/worker-recycling server needs validation. Push-model consumers sidestep this entirely.google/protobuf version — v2.19.1 bumped protobuf 25.7→31.0, which can collide with other Google SDKs in a larger dependency graph.Sequencing
Maintenance
~2.22 and upgrade deliberately rather than floating).Support
Scaling
subscription/backlog_bytes rather than CPU. Throughput per PHP process is modest — this is the weakest scaling story in the package and the main argument against pull.Failure modes
messageId, unique constraints, and idempotent downstream APIs.maxDeliveryAttempts, and dead-letter topics.memory_limit and periodic recycling.ApiException swallowing. The README sample catches and prints; production code must classify retryable vs. terminal (quota exceeded, permission denied, not found) and behave differently.Ramp-up
How can I help you explore Laravel packages today?