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 Pubsub

Cloud Pubsub Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Google Cloud Pub/Sub for PHP is the idiomatic PHP client for Google's fully-managed, real-time messaging service. It lets independent applications send and receive messages reliably at scale, supporting both REST over HTTP/1.1 and gRPC (including streaming methods). Install it via Composer with google/cloud-pubsub and authenticate using Google Cloud credentials.

  • Topic & subscription management with a typed PublisherClient
  • gRPC support for high-performance streaming calls
  • Structured request objects with JSON serialization helpers
  • Exception handling via ApiException for network failures
  • GA stability with no backward-incompatible changes in minor releases
Frequently asked questions about Cloud Pubsub
How do I install google/cloud-pubsub in a Laravel application?
Install it with Composer using composer require google/cloud-pubsub. In Laravel, bind a client or publisher wrapper in a service provider and inject it where needed. There is no Laravel-specific installer or facade, so you write the integration glue yourself. For gRPC, also install the PHP gRPC extension.
Does google/cloud-pubsub integrate with Laravel queues?
Not natively. The package is a Google Cloud Pub/Sub client, not an Illuminate\Queue driver, so Laravel's queue API will not use it without a custom adapter. You can build a queue driver or publisher wrapper around it for high-throughput jobs. Many teams use it for cross-service events instead of replacing Laravel's local queue.
Which Laravel and PHP versions are compatible with google/cloud-pubsub?
The package is framework-agnostic and does not ship Laravel version constraints. For Laravel 9+ on PHP 8.1+, it fits modern applications, but pin google/cloud-pubsub to a release compatible with your PHP runtime. Check Packagist and the Google Cloud PHP repository for current requirements.
How should I authenticate google/cloud-pubsub in Laravel?
Use Google Application Default Credentials or a service account with least-privilege Pub/Sub roles. Store credentials outside source control and load them through Laravel's config/services.php or environment variables. Avoid hardcoding JSON keys in .env files; use Google's auth library or workload identity where possible.
Should I use gRPC or REST for google/cloud-pubsub in Laravel?
Use gRPC when possible because it offers lower latency, higher throughput, and streaming pull support. It requires the PHP gRPC extension, typically installed with pecl install grpc. Fall back to REST if your Laravel host cannot install gRPC, accepting higher latency.
Can Google Cloud Pub/Sub replace Laravel's queue system?
It can for high-throughput or cross-service workloads, but not as a drop-in replacement. Laravel expects an Illuminate\Queue driver, and google/cloud-pubsub does not provide one, so you need a custom adapter or a separate publishing layer. Keep Redis or database queues for local fallback and critical paths if needed.
How do I handle failed Pub/Sub messages in Laravel?
Configure dead-letter queues on Pub/Sub subscriptions and route exhausted messages there. In your Laravel consumer jobs, catch exceptions and nack or ack messages deliberately instead of swallowing errors. Monitor the DLQ and alert on failures so messages are not lost.
Is google/cloud-pubsub good for Laravel microservices communication?
Yes, it suits asynchronous microservices because services can publish and subscribe without direct HTTP dependencies. Publish domain events such as OrderCreated from Laravel listeners and consume them in other services. Abstract Pub/Sub behind interfaces to reduce vendor lock-in and ease testing.
How can I test google/cloud-pubsub integration in Laravel?
Unit test your publisher and subscriber wrappers with mocks or fakes behind interfaces. For integration tests, use the Pub/Sub emulator or a dedicated GCP test project with isolated topics and subscriptions. Do not rely on production credentials in CI.
What are alternatives to google/cloud-pubsub for Laravel messaging?
Alternatives include Laravel's native Redis, database, or SQS queues, plus RabbitMQ or Kafka for broader event streaming. Choose Pub/Sub when you are already on Google Cloud and need managed push or pull messaging. If portability matters, wrap the client behind your own interfaces.
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.
encore2/laravel-admin2
cboxdk/laravel-console-kit
shapecode/doctrine-dbal-datetimeutc
gilads-otiannoh254/inertia-protocol
dakiquang/laravel-oauth-refresh-lock
woda/laravel-worktrees
dalefranks/ramasite
faghy/laracashbook
roundly-consulting/google-places-for-laravel
roundly-consulting/kubernetes-api-for-laravel
roundly-consulting/plausible-for-laravel
gvp/gvp-laravel-template
metasyncsite/laravel-metasync-client
roundly-consulting/onboarding-for-laravel
adachsoft/cli-process-tester
adachsoft/changelog-linter
adachsoft/collection
adachsoft/php-code-style
adachsoft/api-version-bundle
cgv/localized-resource