承接 offload-project/laravel-google-pubsub 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

offload-project/laravel-google-pubsub

Composer 安装命令:

composer require offload-project/laravel-google-pubsub

包简介

Google Cloud Pub/Sub for Laravel with full feature support

README 文档

README

Latest Version on Packagist Tests Build Total Downloads License: MIT

A comprehensive Google Cloud Pub/Sub integration for Laravel that goes beyond a basic queue driver — a complete toolkit for event-driven architectures, microservice communication, and real-time data pipelines.

Features

  • Full Laravel queue driver — drop-in replacement for any other queue connection
  • Publisher / Subscriber services — direct publishing with compression, metadata, and batch support
  • Event integration — bidirectional flow between Laravel events and Pub/Sub topics
  • Webhook support — handle push subscriptions with built-in IP allowlist and token verification
  • Schema validation — JSON Schema validation for message contracts
  • Streaming support — real-time, lower-latency processing with StreamingPull
  • CloudEvents support — industry-standard event formatting with v1.0 compatibility
  • Dead-letter topics & retry policies — auto-wired for resilient message delivery
  • Emulator support — local development with the Google Cloud Pub/Sub emulator
  • Laravel Octane compatible — connection pooling and warm bindings
  • Rich Artisan command set — manage topics, subscriptions, publishing, and listening from the CLI

Table of Contents

Requirements

  • PHP 8.3+
  • Laravel 11 / 12 / 13
  • A Google Cloud project with the Pub/Sub API enabled (or the Pub/Sub emulator for local development)

Installation

composer require offload-project/laravel-google-pubsub

php artisan vendor:publish --provider="OffloadProject\GooglePubSub\PubSubServiceProvider" --tag="config"

Add the basics to your .env:

QUEUE_CONNECTION=pubsub
GOOGLE_CLOUD_PROJECT_ID=your-project-id

# Authentication — pick one
PUBSUB_AUTH_METHOD=application_default
# or
PUBSUB_AUTH_METHOD=key_file
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

Then add a pubsub connection to config/queue.php:

'connections' => [
    'pubsub' => [
        'driver' => 'pubsub',
        'project_id' => env('GOOGLE_CLOUD_PROJECT_ID'),
        'queue' => env('PUBSUB_DEFAULT_QUEUE', 'default'),
        'auth_method' => env('PUBSUB_AUTH_METHOD', 'application_default'),
        'key_file' => env('GOOGLE_APPLICATION_CREDENTIALS'),
        'auto_create_topics' => true,
        'auto_create_subscriptions' => true,
        'subscription_suffix' => '-laravel',
        'enable_message_ordering' => false,
    ],
],

See the Configuration reference for every option.

Quick Start

1. Basic Queue Usage

Use it exactly like any other Laravel queue:

ProcessPodcast::dispatch($podcast);

// Dispatch to a specific topic
ProcessPodcast::dispatch($podcast)->onQueue('audio-processing');

2. Direct Publishing

use OffloadProject\GooglePubSub\Facades\PubSub;

PubSub::publish('orders', [
    'order_id' => 123,
    'total' => 99.99,
    'customer_id' => 456,
]);

// With attributes and an ordering key
PubSub::publish('orders', $data, [
    'priority' => 'high',
    'source' => 'api',
], [
    'ordering_key' => 'customer-456',
]);

3. Event Integration

use OffloadProject\GooglePubSub\Attributes\PublishTo;
use OffloadProject\GooglePubSub\Contracts\ShouldPublishToPubSub;

#[PublishTo('orders')]
class OrderPlaced implements ShouldPublishToPubSub
{
    public function __construct(public Order $order) {}

    public function pubsubTopic(): string
    {
        return 'orders';
    }

    public function toPubSub(): array
    {
        return [
            'order_id' => $this->order->id,
            'total' => $this->order->total,
            'customer_id' => $this->order->customer_id,
        ];
    }
}

event(new OrderPlaced($order));

4. Subscribing to Messages

use OffloadProject\GooglePubSub\Facades\PubSub;

$subscriber = PubSub::subscribe('orders-processor', 'orders');

$subscriber->handler(function ($data, $message) {
    processOrder($data);
});

$subscriber->listen();

Full Documentation

AI Coding Assistant Skill

This package ships a Laravel Boost skill so coding assistants (Claude Code, Cursor, etc.) follow the package's conventions when generating code. Install it in your app with:

php artisan boost:add-skill offload-project/laravel-google-pubsub

The skill source lives at skills/SKILL.md.

Testing

composer test

Contributing

Contributions are welcome! Please see the documents below before getting started.

Security

License

The MIT License (MIT). Please see License File for more information.

offload-project/laravel-google-pubsub 适用场景与选型建议

offload-project/laravel-google-pubsub 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 128 次下载、GitHub Stars 达 8, 最近一次更新时间为 2025 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「google」 「cloud」 「laravel」 「pubsub」 「gcp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 offload-project/laravel-google-pubsub 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 offload-project/laravel-google-pubsub 我们能提供哪些服务?
定制开发 / 二次开发

基于 offload-project/laravel-google-pubsub 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 128
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 23
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-16