PHPackages                             bernardwiesner/laravel-gcp-pubsub - 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. bernardwiesner/laravel-gcp-pubsub

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

bernardwiesner/laravel-gcp-pubsub
=================================

Wrapper over Google Cloud PubSub for PHP

v1.0(3y ago)57MITPHPPHP &gt;=7.2

Since Sep 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bernardwiesner/laravel-gcp-pubsub)[ Packagist](https://packagist.org/packages/bernardwiesner/laravel-gcp-pubsub)[ RSS](/packages/bernardwiesner-laravel-gcp-pubsub/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Overview
========

[](#overview)

Wrapper over [Google Cloud PubSub for PHP](https://github.com/googleapis/google-cloud-php-pubsub).

This wrapper provides a convenient fluent API and has some usefull features such as timeout, retries and a delay API method. It also provides a mock facade for testing.

The recommended way to use this package is setting up a PubSub API with laravel that processes [push](https://cloud.google.com/pubsub/docs/push) subscription events from GCP pubsub. You can then `publish` topics from any of your microservices in laravel to GCP pubsub, and GCP will call your configured `push` subscription endpoints (APIs) to process the job. This is an alternative over using laravel queue for processing background jobs.

The advantage of using this package over [laravel queue](https://laravel.com/docs/9.x/queues), is you can easily scale your APIs by simply adding more servers or containers. Another big advantage is it decouples your jobs from your code, there is no need to define your jobs in the same repo as from where they are dispatched/published, allowing for a firendlier microservice architecture. You could even process the jobs in another language other than PHP/laravel in one of your microservices.

For more details on how to setup a PubSub API with laravel refer to [this guide](https://dev.to/bernardwiesner/laravel-microservice-using-gcp-pubsub-an-alternative-to-laravel-queue-2inc).

### Installation

[](#installation)

```
composer require bernardwiesner/laravel-gcp-pubsub
```

### Publish config

[](#publish-config)

If you would like to adjust the retry attemps, or modify some of the other configurations you should publish the config:

```
php artisan vendor:publish --tag=gcp-pubsub
```

### Transport protocol

[](#transport-protocol)

By default the wrapper is using http 1.1 REST. I have tested with gRPC and observed a slower response rate. If you would like to use gRPC instead you can modify the `transport` inside the `gcp-pubsub.php` config file:

```
