PHP code example of luqman-v1 / pubsub

1. Go to this page and download the library: Download luqman-v1/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/ */

    

luqman-v1 / pubsub example snippets


'providers' => [
    // ...
    LuqmanV1\PubSub\PubSubServiceProvider::class,
]

'aliases' => [
    // ...
    'PubSub' => LuqmanV1\PubSub\Facade::class,
]

    //for publish message
    $message = [
            'data'       => 'My new message.',
            'attributes' => [
                'location' => 'Detroit',
            ],
        ];
    PubSub::publish("someTopicName", $message);
    
    //for pull message 
     $messages = PubSub::pull("someSubcriberName");
     foreach($messages as $message){
        echo $message->data() . "\n";
        echo $message->attribute('location');
     }
     
     //for another function like create topic or etc 
     call function :  PubSub::pubsub()->methodYouWantUse();
     example :
     PubSub::pubsub()->createTopic('someNewTopicName');