PHP code example of intreguei / gcp-pubsub

1. Go to this page and download the library: Download intreguei/gcp-pubsub library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

intreguei / gcp-pubsub example snippets




use Intreguei\GcpPubsub\PubSub;

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

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




use Intreguei\GcpPubsub\PubSub;

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

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

}