PHPackages                             jag/laravel-broadcaster-google-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. [API Development](/categories/api)
4. /
5. jag/laravel-broadcaster-google-pubsub

ActiveLibrary[API Development](/categories/api)

jag/laravel-broadcaster-google-pubsub
=====================================

Google PubSub on Laravel Broadcaster

v0.1.0(6y ago)06[1 issues](https://github.com/jayaregalinada/laravel-broadcaster-google-pubsub/issues)MITPHPPHP ^7.1CI failing

Since May 5Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (10)Versions (2)Used By (0)

Google PubSub (Laravel Broadcaster)
===================================

[](#google-pubsub-laravel-broadcaster)

Laravel Broadcaster using [Google PubSub](https://cloud.google.com/pubsub/)

> **⚠️ NOTE: Currently on development, changes may drastically occur without further notice**

### Requirements

[](#requirements)

- PHP `^7.1`
- Laravel/Lumen `^7.0` [(support older version?: issue#1)](https://github.com/jayaregalinada/laravel-broadcaster-google-pubsub/issues/1)
- [gRPC](https://cloud.google.com/php/grpc) (Optional but increase performance)

### Getting Started

[](#getting-started)

##### Install Composer

[](#install-composer)

```
composer require jag/laravel-broadcaster-google-pubsub
```

##### Add Service Provider

[](#add-service-provider)

Since Laravel 5.5 [Auto Discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518) is enabled by default, but in case you disable or uses [Lumen Framework](https://lumen.laravel.com), add the service provider:

On `config/app.php`

```
...
'providers' => [
    ...
    Jag\Broadcaster\GooglePubSub\Providers\LaravelPubSubServiceProvider::class,
]
...
```

If Lumen however, on your `bootstrap/app.php`

```
...
$app->register(Jag\Broadcaster\GooglePubSub\Providers\LaravelPubSubServiceProvider::class);
...
```

### Configuration

[](#configuration)

##### In Laravel &amp; Lumen

[](#in-laravel--lumen)

Make sure your `BROADCAST_DRIVER` is `google`

On your `.env`

```
...
BROADCAST_DRIVER=google
GOOGLE_PUBSUB_BROADCASTER_PROJECT_ID=insert-your-google-project-id-here
GOOGLE_PUBSUB_BROADCASTER_CREDENTIALS=path/to/your/key.json

```

##### In Lumen

[](#in-lumen)

In case you are using Lumen, you need to copy broadcasting configuration usually found at `vendor/laravel/lumen-framework/config/broadcasting.php` to your `config/broadcasting.php`, then add these configuration:

```
return [
    'default' => env('BROADCAST_DRIVER', 'null'),
    'connections' => [
        // Usually other connections here like pusher, redis, log & null by default
        'google' => [
            'driver' => 'google',
            'project_id' => env('GOOGLE_PUBSUB_BROADCASTER_PROJECT_ID', env('GOOGLE_PROJECT_ID', env('GCLOUD_PROJECT'))),
            'credentials_path' => env('GOOGLE_PUBSUB_BROADCASTER_CREDENTIALS', env('GOOGLE_APPLICATION_CREDENTIALS')),
            'auto_create_topic' => env('GOOGLE_PUBSUB_BROADCASTER_AUTO_CREATE_TOPIC', false),
            'override_config' => [],
        ]
    ],
];
```

You can also find these configuration at `vendor/jag/laravel-broadcaster-google-pubsub/config/google.php`

> Configuration `GOOGLE_PUBSUB_BROADCASTER_CREDENTIALS` if `null` or not present, will automatically search for `storage/key.json`.

> If you also add like this `GOOGLE_PUBSUB_BROADCASTER_CREDENTIALS=storage/google-key.json` in your `.env`, it will search for `storage/google-key.json`, just a magic use of `Str::startsWith` [documentation](https://laravel.com/docs/7.x/helpers#method-starts-with).

> You can enable auto creation of topic in `auto_create_topic` (`boolean type, default false`), **BUT** make sure your credentials have permission of `Pub/Sub Viewer`.

> You can also override most of all [PubSubClient](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.132.0/pubsub/pubsubclient) related configuration on `override_config` **EXCEPT** `projectId`:

```
// broadcasting.php
return [
    ...
    'connections' => [
        'google' => [
            ...// Default configuration
            'override_config' => [
                'retries' => 5,
                'requestTimeout' => 120,
            ],
        ]
    ],
];
```

KeyDescriptionTypeDefaultproject\_idPubSub Project IDStringenv('GOOGLE\_PUBSUB\_BROADCASTER\_PROJECT\_ID', env('GOOGLE\_PROJECT\_ID', env('GCLOUD\_PROJECT')))credentials\_pathPath for credentialsStringenv('GOOGLE\_PUBSUB\_BROADCASTER\_CREDENTIALS', env('GOOGLE\_APPLICATION\_CREDENTIALS'))auto\_create\_topicCreate Topic if non-existingBooleanenv('GOOGLE\_PUBSUB\_BROADCASTER\_AUTO\_CREATE\_TOPIC', false),override\_configOverride configuration except projectIdArray\[\]Usage
-----

[](#usage)

To use these in your Events, make sure to implement `Illuminate\Contracts\Broadcasting\ShouldBroadcast` and add the topic on `broadcastOn()`.

```
// App\Events\NewlyCreatedProductEvent.php
...
class NewlyCreatedProductEvent implements ShouldBroadcast {
    ...
    public function broadcastOn()
    {
        return [
            'text-based-topic-name',
            new ProductChannel()
        ];
    }
}
```

On your channel, the topic name will be based on channel's name

```
// App\Broadcasting\ProductChannel
...
class ProductChanel extends Channel
{
    public function __construct()
    {
        parent::__construct('product-topic');
    }
}
```

But you can also override this by `$topic` public property.

```
// App\Broadcasting\ProductChannel
...
class ProductChanel extends Channel
{
    // or the fully name topic eg. projects/project-id/topics/topic-id
    public $topic = 'override-topic-name';

    public function __construct()
    {
        parent::__construct('product-topic');
    }
}
```

---

###### Created and Developed by [Jay Are Galinada](https://jayaregalinada.github.io)

[](#created-and-developed-by-jay-are-galinada)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2199d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ccb2da23632346595380271ccb477d6f054912dde484fb463818d2d5b5b0ae19?d=identicon)[jayaregalinada](/maintainers/jayaregalinada)

---

Top Contributors

[![jayaregalinada](https://avatars.githubusercontent.com/u/1170288?v=4)](https://github.com/jayaregalinada "jayaregalinada (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jag-laravel-broadcaster-google-pubsub/health.svg)

```
[![Health](https://phpackages.com/badges/jag-laravel-broadcaster-google-pubsub/health.svg)](https://phpackages.com/packages/jag-laravel-broadcaster-google-pubsub)
```

###  Alternatives

[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[dragon-code/laravel-json-response

Automatically always return a response in JSON format

1118.6k1](/packages/dragon-code-laravel-json-response)

PHPackages © 2026

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