Download the PHP package gdg-tangier/cloud-pubsub without Composer
On this page you can find all versions of the php package gdg-tangier/cloud-pubsub. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gdg-tangier/cloud-pubsub
More information about gdg-tangier/cloud-pubsub
Files in gdg-tangier/cloud-pubsub
Package cloud-pubsub
Short Description Google Cloud pub-sub for laravel
License MIT
Informations about the package cloud-pubsub
Laravel Cloud Pub/Sub.
Why?
Build a scalable Laravel apps using event-driven microservices architecture (Pub/Sub), this tool adds the ability for your Laravel applications to communicate with each other using Google Cloud Pub/Sub.
Define your architecture.
First of all, you need to create subscriptions and topics in Google Cloud Platform, or you can use the cli.
Installation.
composer require gdg-tangier/cloud-pubsub
Configuration.
config/queue.php
You can define multiple subscribers (queue connections) config in config/queue.php
, the app can subscribe to multiple subscriptions.
Example.
config/pubsub.php
Here where you can define your subscriptions
jobs, events and topics mappings.
Example.
Create subscription class.
php artisan pubsub:make-subscriber <Name>
A subscription class will be created at app/Subscribers
Example.
Publishing data to the cloud.
-
Using facade.
-
Using service container.
- Using artisan command.
php artisan pubsub:publish <message> <event>
Subscriptions worker.
php artisan pubsub:subscribe <connection>
Or alternatively you can run php artisan queue:work <connection>
Note: To keep the queue:subscribe process running permanently in the background, you should use a process monitor such as supervisor to ensure that the queue worker does not stop running.
Using GCP Pub/Sub emulator.
You need to install GCP command line tool and Setup Topics/Subscriptions
To use the emulator:
-
Go to the
AppServiceProvider@register
and addPubSub::useEmulatorCredentials()
-
Export the pubsub emulator host
export PUBSUB_EMULATOR_HOST=localhost:8085
- Run the emulator,
php artisan pubsub:emulator
Testing.
You need to install GCP command line tool.
- Run the pubsub emulator
./emulator.sh
- Export the pubsub emulator host
export PUBSUB_EMULATOR_HOST=localhost:8085
- Run
phpunit