PHPackages                             superbalist/php-pubsub-google-cloud - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. superbalist/php-pubsub-google-cloud

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

superbalist/php-pubsub-google-cloud
===================================

A Google Cloud adapter for the php-pubsub package

5.2.0(7y ago)12169.4k↓40.9%11[1 PRs](https://github.com/Superbalist/php-pubsub-google-cloud/pulls)9MITPHPPHP &gt;=5.6.0

Since Sep 4Pushed 3y ago34 watchersCompare

[ Source](https://github.com/Superbalist/php-pubsub-google-cloud)[ Packagist](https://packagist.org/packages/superbalist/php-pubsub-google-cloud)[ RSS](/packages/superbalist-php-pubsub-google-cloud/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (23)Used By (9)

php-pubsub-google-cloud
=======================

[](#php-pubsub-google-cloud)

A Google Cloud adapter for the [php-pubsub](https://github.com/Superbalist/php-pubsub) package.

[![Author](https://camo.githubusercontent.com/abd4e3e2e71081ad01ef09a60c49d70c5e0677497f38918e740703cd02605078/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d40737570657262616c6973742d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/superbalist)[![Build Status](https://camo.githubusercontent.com/be272cefd6480cbe3aeefbe92168e0e4e3e06cfa76b26dfdd9de83b9570156f5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f537570657262616c6973742f7068702d7075627375622d676f6f676c652d636c6f75642f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Superbalist/php-pubsub-google-cloud)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/5bb61e1f64e754c644dad4cf4092cdf363e4d4c8990edcf3ec46c51889f7133c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737570657262616c6973742f7068702d7075627375622d676f6f676c652d636c6f75642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/superbalist/php-pubsub-google-cloud)[![Total Downloads](https://camo.githubusercontent.com/126a8b7131c15e34f515e81fdaa7bb514642bd58e31c3690de23bd9a4f0bee21/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737570657262616c6973742f7068702d7075627375622d676f6f676c652d636c6f75642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/superbalist/php-pubsub-google-cloud)

Installation
------------

[](#installation)

```
composer require superbalist/php-pubsub-google-cloud
```

Usage
-----

[](#usage)

```
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . __DIR__ . '/../your-gcloud-key.json');

$client = new \Google\Cloud\PubSub\PubSubClient([
    'projectId' => 'your-project-id-here',
]);

$adapter = new \Superbalist\PubSub\GoogleCloud\GoogleCloudPubSubAdapter($client);

// disable auto topic & subscription creation
$adapter->setAutoCreateTopics(false); // this is true by default
$adapter->setAutoCreateSubscriptions(false); // this is true by default

// set a unique client identifier for the subscriber
$adapter->setClientIdentifier('search_service');

// consume messages
// note: this is a blocking call
$adapter->subscribe('my_channel', function ($message) {
    var_dump($message);
});

// publish messages
$adapter->publish('my_channel', 'HELLO WORLD');
$adapter->publish('my_channel', json_encode(['hello' => 'world']));
$adapter->publish('my_channel', 1);
$adapter->publish('my_channel', false);
```

gRPC Support
------------

[](#grpc-support)

Google Cloud PHP v0.12.0 added support for communication over the gRPC protocol.

> gRPC is great for high-performance, low-latency applications, and is highly recommended in cases where performance and latency are concerns.

The library will automatically choose gRPC over REST if all dependencies are installed.

- [gRPC PECL extension](https://pecl.php.net/package/gRPC)
- [google/proto-client-php composer package](https://github.com/googleapis/gax-php)
- [googleapis/proto-client-php composer package](https://github.com/googleapis/proto-client-php)

```
pecl install grpc

composer require google/gax
composer require google/proto-client
```

Background Batch Message Support
--------------------------------

[](#background-batch-message-support)

Google Cloud v0.33.0 added support for queueing messages and publishing in the background. This is available in version 5+ of this package which requires a min version of google/cloud ^0.33.0.

You can enable background batch messaging by setting `$backgroundBatching` to `true` when constructing the `GoogleCloudPubSubAdapter` or by calling `setBackgroundBatching(true)` on an existing adapter.

If the [semaphore](http://php.net/manual/en/book.sem.php) and [pcntl](http://php.net/manual/en/book.pcntl.php) PHP extensions are enabled AND the `IS_BATCH_DAEMON_RUNNING` ENV var is set to `true`, the library will queue messages to be published by the [Batch Daemon](https://github.com/GoogleCloudPlatform/google-cloud-php/blob/master/src/Core/Batch/BatchDaemon.php). The Batch Daemon needs to be manually run as a long-lived background process.

For all other cases, messages will be queued in memory and will be published before the script terminates using a vendor registered shutdown handler.

**Please Note**

This is marked by google/cloud as an experimental feature &amp; may change before release in backwards-incompatible ways.

Examples
--------

[](#examples)

The library comes with [examples](examples) for the adapter and a [Dockerfile](Dockerfile) for running the example scripts.

Run `make up`.

You will start at a `bash` prompt in the `/opt/php-pubsub` directory.

If you need another shell to publish a message to a blocking consumer, you can run `docker-compose run php-pubsub-google-cloud /bin/bash`

To run the examples:

```
$ php examples/GoogleCloudConsumerExample.php
$ php examples/GoogleCloudPublishExample.php (in a separate shell)
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 62% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~101 days

Recently: every ~205 days

Total

16

Last Release

2029d ago

Major Versions

1.0.2 → 2.0.02016-10-05

2.0.2 → 3.0.02017-01-03

3.0.1 → 4.0.02017-05-16

4.0.1 → 5.0.02017-07-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b8f533cf5a84c29d3860ee32356f0554ead023247638ea952353fc2f01b2e5d?d=identicon)[superbalist](/maintainers/superbalist)

---

Top Contributors

[![matthewgoslett](https://avatars.githubusercontent.com/u/1571743?v=4)](https://github.com/matthewgoslett "matthewgoslett (31 commits)")[![geyer-za](https://avatars.githubusercontent.com/u/6848791?v=4)](https://github.com/geyer-za "geyer-za (15 commits)")[![shad0wfir3](https://avatars.githubusercontent.com/u/20926935?v=4)](https://github.com/shad0wfir3 "shad0wfir3 (3 commits)")[![nicja](https://avatars.githubusercontent.com/u/2102143?v=4)](https://github.com/nicja "nicja (1 commits)")

---

Tags

google-cloudgoogle-cloud-platformgoogle-cloud-pubsubphpphp-pubsubpubsubsuperbalist

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/superbalist-php-pubsub-google-cloud/health.svg)

```
[![Health](https://phpackages.com/badges/superbalist-php-pubsub-google-cloud/health.svg)](https://phpackages.com/packages/superbalist-php-pubsub-google-cloud)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
