2017 © Pedro Peláez
 

library php-pubsub-google-cloud

A Google Cloud adapter for the php-pubsub package

image

superbalist/php-pubsub-google-cloud

A Google Cloud adapter for the php-pubsub package

  • Friday, July 27, 2018
  • by matthewgoslett
  • Repository
  • 23 Watchers
  • 4 Stars
  • 21,948 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 17 Versions
  • 15 % Grown

The README.md

php-pubsub-google-cloud

A Google Cloud adapter for the php-pubsub package., (*1)

Author Build Status Software License Packagist Version Total Downloads, (*2)

Installation

composer require superbalist/php-pubsub-google-cloud

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

Google Cloud PHP v0.12.0 added support for communication over the gRPC protocol., (*3)

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

The library will automatically choose gRPC over REST if all dependencies are installed. * gRPC PECL extension * google/proto-client-php composer package * googleapis/proto-client-php composer package, (*5)

pecl install grpc

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

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., (*6)

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

If the semaphore and pcntl 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. The Batch Daemon needs to be manually run as a long-lived background process., (*8)

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

Please Note, (*10)

This is marked by google/cloud as an experimental feature & may change before release in backwards-incompatible ways., (*11)

Examples

The library comes with examples for the adapter and a Dockerfile for running the example scripts., (*12)

Run make up., (*13)

You will start at a bash prompt in the /opt/php-pubsub directory., (*14)

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, (*15)

To run the examples:, (*16)

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

The Versions

27/07 2018

dev-master

9999999-dev

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

27/07 2018

dev-revert-9-copyright-date

dev-revert-9-copyright-date

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

27/07 2018

dev-copyright-date

dev-copyright-date

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

27/07 2018

5.0.1

5.0.1.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

27/07 2018

dev-max-messages

dev-max-messages

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

16/04 2018

dev-update-dependencies

dev-update-dependencies

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

25/07 2017

5.0.0

5.0.0.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

21/07 2017

4.0.1

4.0.1.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

16/05 2017

4.0.0

4.0.0.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/04 2017

3.0.1

3.0.1.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/01 2017

3.0.0

3.0.0.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/01 2017

2.0.2

2.0.2.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

05/10 2016

2.0.1

2.0.1.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

05/10 2016

2.0.0

2.0.0.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

26/09 2016

1.0.2

1.0.2.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

15/09 2016

1.0.1

1.0.1.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

04/09 2016

1.0.0

1.0.0.0

A Google Cloud adapter for the php-pubsub package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd