genesis-global / gps-messenger-bundle
Fork of petitpress/gps-messenger-bundle with support for PHP 7.3
Installs: 1 082
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 17
Type:symfony-bundle
Requires
- php: >=7.2.0
- ext-json: *
- google/cloud-pubsub: ^1.29
- symfony/messenger: ^4.4|^5.1
- symfony/options-resolver: ^4.4|^5.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.17
- jangregor/phpstan-prophecy: ^0.8.1
- phpspec/prophecy-phpunit: ^1.1
- phpstan/phpstan: ^0.12.64
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2025-02-20 13:34:43 UTC
README
This bundle provides a simple implementation of Google Pub/Sub transport for Symfony Messenger.
The bundle requires only symfony/messenger
, google/cloud-pubsub
and symfony/options-resolver
packages.
In contrast with Enqueue GPS transport,
it doesn't require Enqueue
and some bridge.
It supports ordering messages with OrderingKeyStamp
and it's not outdated.
Installation
Step 1: Install the Bundle
From within container execute the following command to download the latest version of the bundle:
$ composer require petitpress/gps-messenger-bundle --no-scripts
Step 2: Configure environment variables
Official Google Cloud PubSub SDK requires some globally accessible environment variables.
You might need to change default Symfony DotEnv instance to use putenv
as Google needs to access some variables through getenv
. To do so, use putenv method in config/bootstrap.php
:
(new Dotenv())->usePutenv()->...
List of Google Pub/Sub configurable variables :
# use these for production environemnt: GOOGLE_APPLICATION_CREDENTIALS='google-pubsub-credentials.json' GCLOUD_PROJECT='project-id' # use these for development environemnt (if you have installed Pub/Sub emulator): PUBSUB_EMULATOR_HOST=http://localhost:8538
Step 3: Configure Symfony Messenger
# config/packages/messenger.yaml framework: messenger: transports: gps_transport: dsn: 'gps://default' options: key_file_path: /path/to/gcp-key.json #optional. Can be used instead of setting environment variables. max_messages_pull: 10 # optional (default: 10) topic: # optional (default name: messages) name: 'messages' queue: # optional (default the same as topic.name) name: 'messages' batch_size: 0 # optional (default: 0) If set above 0 it uses pubsubs batch publisher
or:
# config/packages/messenger.yaml framework: messenger: transports: gps_transport: dsn: 'gps://default/messages?max_messages_pull=10&key_file_path=/path/to/gcp-key.json'
Step 4: Use available stamps if needed
OrderingKeyStamp
: use for keeping messages of the same context in order. For more information, read an official documentation.