PubSub/src/Topic.php
public function publishBatch(array $messages, array $options = [])
    {
        foreach ($messages as &$message) {
            $message = $this->formatMessage($message);
        }

        return $this->connection->publishMessage($options + [
            'topic' => $this->name,
            'messages' => $messages
        ]);
    }
public function publishBatch(array $messages, array $options = [])
    {
        foreach ($messages as &$message) {
            $message = $this->formatMessage($message);
        }

        return $this->connection->publishMessage($options + [
            'topic' => $this->name,
            'messages' => $messages
        ]);
    }
public function publishBatch ( array $ messages , array $ options = [ ] ) { foreach ( $ messages as & $ message ) { $ message = $ this -> formatMessage ( $ message ) ; } return $ this -> connection -> publishMessage ( $ options + [ 'topic' => $ this -> name , 'messages' => $ messages ] ) ; }
Publish multiple messages at once.

Example:
```
$topic->publishBatch([
[
'data' => 'New User Registered',
'attributes' => [
'id' => '1',
'userName' => 'John',
'location' => 'Detroit'
]
], [
'data' => 'New User Registered',
'attributes' => [
'id' => '2',
'userName' => 'Steve',
'location' => 'Mountain View'
]
]
]);
```

@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/publish Publish Message

@param array $messages A list of messages. Each message must be in the correct
[Message Format](https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage).
@param array $options [optional] Configuration Options
@return array A list of message IDs.
Publish multiple messages at once .