Weave Code
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 Pubsub

Cloud Pubsub Laravel Package

google/cloud-pubsub

Idiomatic PHP client for Google Cloud Pub/Sub. Publish and consume messages between services using REST or gRPC (streaming supported). Install via Composer (google/cloud-pubsub) and authenticate with Google Cloud credentials.

View on GitHub
Deep Wiki
Context7

google/cloud-pubsub is the idiomatic PHP client for Google Cloud Pub/Sub, enabling reliable, real-time messaging between independent services. It supports both REST (HTTP/1.1) and gRPC transports, with first-class integration into the broader Google Cloud PHP ecosystem and GA stability.

Use it to publish and consume messages, manage topics/subscriptions, and build event-driven systems with authenticated Google Cloud access.

  • Publish/consume messages with Cloud Pub/Sub primitives
  • Choose REST or gRPC, including streaming benefits with gRPC
  • GA component with stable, backwards-compatible releases
  • Clear API reference and samples for quick integration
  • Works with Google Cloud authentication and debugging guides
Frequently asked questions about Cloud Pubsub
How do I integrate Google Cloud Pub/Sub into a Laravel application for event-driven workflows?
Use the `google/cloud-pubsub` package to publish messages from Laravel services (e.g., order processing) to Pub/Sub topics. Consumers like Laravel Queues or Cloud Functions can subscribe to these topics. For example, publish events via `PublisherClient` and process them asynchronously with `SubscriptionClient`. The package supports both REST and gRPC for flexibility.
Does google/cloud-pubsub work with Laravel’s queue system? Can it replace Laravel Queues?
Yes, it can replace or extend Laravel Queues for distributed workloads. Publish messages to Pub/Sub topics from Laravel jobs, then consume them via Pub/Sub subscriptions. This is ideal for high-throughput or cross-service workflows. Use `SubscriptionClient` to pull messages and process them in Laravel jobs or serverless functions.
What Laravel versions and PHP requirements does google/cloud-pubsub support?
The package supports PHP 8.4+ and is compatible with Laravel 10.x (latest LTS). It avoids deprecated features and aligns with Laravel’s modern stack. Check the [Google Cloud PHP docs](https://cloud.google.com/php/docs/reference/cloud-pubsub/latest) for version-specific details.
How do I authenticate google/cloud-pubsub in Laravel for Google Cloud access?
Use Laravel’s environment variables to set `GOOGLE_APPLICATION_CREDENTIALS` (path to a service account JSON key). The package automatically picks up credentials from this variable. For production, restrict the service account to specific Pub/Sub topics using IAM roles. Refer to the [authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md).
Can I use gRPC with google/cloud-pubsub for streaming messages in Laravel?
Yes, gRPC is supported for streaming publish/subscribe operations, but it requires additional setup (protobuf compilation and PHP gRPC extensions). Start with REST for simplicity, then migrate to gRPC if you need high-throughput streaming (e.g., real-time logs or notifications). Follow the [gRPC installation guide](https://cloud.google.com/php/grpc).
How do I handle message ordering guarantees in Laravel with Pub/Sub?
Pub/Sub does not guarantee message ordering by default. Use ordering keys in your `PublishRequest` to enforce sequence for critical workflows (e.g., financial transactions). Design consumers to be idempotent and handle duplicates. For Laravel, store processed message IDs in a database to avoid reprocessing.
What are the cost implications of using google/cloud-pubsub in production with Laravel?
Costs depend on message volume, retention periods, and storage. Monitor subscription backlogs and implement dead-letter topics for failed messages. Use Google Cloud’s monitoring tools to track metrics like `subscription/backlog_bytes` and set alerts. For high-volume systems, optimize batch publishing to reduce API calls.
Are there alternatives to google/cloud-pubsub for Laravel if I want to avoid Google Cloud lock-in?
For multi-cloud or self-hosted alternatives, consider RabbitMQ (via `php-amqplib`), AWS SQS (via `aws/aws-sdk-php`), or Apache Kafka (via `rdkafka/rdkafka`). These require additional infrastructure but offer more portability. For Google Cloud, use abstraction layers (e.g., Laravel service contracts) to isolate Pub/Sub logic.
How do I debug issues with google/cloud-pubsub in a Laravel application?
Enable debug logging by setting the `GOOGLE_CLOUD_LOG_LEVEL` environment variable to `DEBUG`. Use the [debugging guide](https://github.com/googleapis/google-cloud-php/blob/main/DEBUG.md) for tools like HTTP request/response logging. For authentication issues, verify your service account JSON key and IAM permissions.
Can I use google/cloud-pubsub for real-time notifications in Laravel, like WebSocket updates?
Yes, combine Pub/Sub with Cloud Functions or Laravel Echo to push real-time updates. Publish events to a topic, then use a Cloud Function to broadcast WebSocket messages via Laravel Echo or a custom HTTP endpoint. This avoids polling and reduces latency for live notifications.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport