Example:
Create subscription through a topic
use Google\Cloud\ServiceBuilder;
$cloud = new ServiceBuilder();
$pubsub = $cloud->pubsub();
$topic = $pubsub->topic('my-topic-name');
$subscription = $topic->subscription('my-new-subscription');
Create subscription through PubSubClient
use Google\Cloud\PubSub\PubSubClient;
$pubsub = new PubSubClient([
'projectId' => 'my-awesome-project'
]);
$subscription = $pubsub->subscription(
'my-new-subscription',
'my-topic-name'
);