intreguei/gcp-pubsub

Pacote criado para publicação e subscrição de tópicos da gcp

v0.0.2 2023-12-21 15:04 UTC

This package is not auto-updated.

Last update: 2024-04-30 13:12:31 UTC


README

This library offers a way to use the subscription of GCP pubsub as broadcast using the google/cloud-pubsub library.

A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

Installation

To begin, install the preferred dependency manager for PHP, Composer.

Now to install just this library:

$ composer require intreguei/gcp-pubsub

Authentication

This library use the Google Cloud PHP authentication. See the Authentication guide for more information on authenticating your client. Once authenticated, you'll be ready to start making requests.

Samples

Publish message on topic:

require 'vendor/autoload.php';

use Intreguei\GcpPubsub\PubSub;

$callback = function ($message) {
    //method to use message from topic
} 

PubSub::listenSubscription('your_topic_name', $callback);

Listen to subscription:

require 'vendor/autoload.php';

use Intreguei\GcpPubsub\PubSub;

$dataToPublish = [
    'key_1' => 'data_1',
    'key_2' => 'data_2',
];

PubSub::publishMessage('your_topic_name', $dataToPublish); 

}

References

  1. Google CLoud official documentation.
  2. Take a look at Google Cloud in-depth usage samples.

Authors

Clezer Aragon & Leandro Lazari