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
Messenger Pubsub

Messenger Pubsub Laravel Package

cedricziel/messenger-pubsub

Symfony Messenger transport bridge for Google Cloud Pub/Sub. Adds a pubsub:// transport via PubSubTransportFactory for publishing and consuming messages from Pub/Sub. Note: Pub/Sub doesn’t support delayed delivery, so DelayStamp is ignored.

View on GitHub
Deep Wiki
Context7

A bridge library to allow consuming and publishing to Google Cloud Pub/Sub with the Symfony Messenger

Frequently asked questions about Messenger Pubsub
How do I integrate this package with Laravel if it’s designed for Symfony Messenger?
This package bridges Symfony Messenger with Google Cloud Pub/Sub, but Laravel can use Symfony Messenger via the `symfony/messenger` package. Install both `cedricziel/messenger-pubsub` and `symfony/messenger`, then configure the `PubSubTransportFactory` in your Laravel service container. Laravel’s dependency injection works with Symfony Messenger’s components, so the setup is compatible.
What Laravel versions and Symfony Messenger versions does this package support?
The package explicitly requires Symfony Messenger 5.4+, which aligns with Laravel 8+ (as Laravel 8+ uses Symfony 5.4+ components). Ensure your Laravel app’s `symfony/messenger` version matches this requirement. Check the package’s `composer.json` for exact constraints, as they may evolve.
Can I use this for delayed message delivery, like retries or scheduled tasks?
No, Google Cloud Pub/Sub does not support delayed message delivery, so Symfony Messenger’s `DelayStamp` is ignored. For delayed tasks, use alternative transports like Doctrine or database queues, or implement a workaround with Pub/Sub’s scheduled subscriptions (though this is not natively supported by this bridge).
How do I handle message failures or dead-letter queues (DLQ) with this transport?
The package does not include built-in DLQ or retry logic. You’ll need to configure Pub/Sub’s dead-letter subscriptions manually in Google Cloud Console and handle acknowledgment failures in your consumer logic. For retries, use Symfony Messenger’s built-in retry middleware or implement custom logic in your message handlers.
What are the security best practices for using this with Google Cloud Pub/Sub?
Use a dedicated service account with least-privilege IAM roles for Pub/Sub access. Store credentials securely (e.g., Laravel’s `.env` or Google Secret Manager). Avoid hardcoding keys in code. For encryption, ensure Pub/Sub messages are serialized securely (e.g., using Symfony’s Serializer with encryption components).
Are there alternatives to this package for Laravel if I want to avoid Google Cloud Pub/Sub?
Yes. For Laravel, consider `symfony/messenger` with other transports like `old_sound/rabbit-mq-bundle` (RabbitMQ), `php-amqplib` (AMQP), or `symfony/amqp-messenger` (AMQP). For AWS, use `symfony/messenger` with `aws/aws-sdk-php` and SQS/SNS. These offer broader feature support, including delayed messages and retries.
How do I test message publishing/consumption with this transport in Laravel?
Mock the `PubSubTransportFactory` and `google/cloud-pubsub` client in your tests. Use Laravel’s `MessengerTestCase` or PHPUnit to verify message dispatching. For consumption tests, simulate Pub/Sub messages with the client library’s mocking tools or a local Pub/Sub emulator like `google-cloud-pubsub-emulator`. Validate serialization/deserialization of your message objects.
Will this work in a serverless environment like Cloud Functions or Kubernetes?
Yes, but configure Pub/Sub with appropriate IAM permissions and ensure your environment can handle the Google Cloud PHP client’s dependencies. For Kubernetes, use a sidecar container for the Pub/Sub client or deploy the client in the same pod. Monitor resource usage, as Pub/Sub consumers may block if not managed properly.
How do I monitor message throughput, errors, or latency with this transport?
Use Google Cloud’s Pub/Sub metrics (e.g., `subscription/backlog_messages`, `publish_requests`) via the GCP Console or APIs. For application-level monitoring, integrate Symfony Messenger’s `Bus` with Prometheus or OpenTelemetry via middleware. Log message IDs and timestamps in your handlers to track latency manually.
Is there a bundle version of this package for easier Laravel integration?
Yes, the `cedricziel/symfony-messenger-pubsub-bundle` provides automatic wiring for Symfony Framework applications, including Laravel. It simplifies configuration by handling service registration and transport setup. Use this if you prefer a bundle-based approach over manual `services.yaml`/`messenger.yaml` configuration.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai