定制 teamsquad.io/php-event-bus 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

teamsquad.io/php-event-bus

Composer 安装命令:

composer require teamsquad.io/php-event-bus

包简介

A basic PHP EventBus Library

关键字:

README 文档

README

TeamSquad PHP EventBus library package.

Source Code Download Package PHP Programming Language Build Status Codecov Code Coverage Psalm Type Coverage

This is the TeamSquad PHP EventBus Library. It's used to publish and listen to events.

Installation

composer require teamsquad/php-event-bus

Development

Initialization

composer install

Run composer scripts

composer test-all     # run test-quality & test-phpunit
composer test-quality # run csrun & psalm & phpstan
composer test-phpunit # run phpunit

composer csrun   # check code style
composer psalm   # run psalm coverage
composer phpstan # run phpstan coverage

Git hooks

Install the pre-commit hook running:

./tools/git-hooks/init.sh

Basic Dockerfile

If you don't have PHP in your local machine, you can use docker to build an image with PHP 8.0.

docker build -t php-event-bus .

Contributing

Feel free to open any PR with your ideas, suggestions or improvements.

Consumer configuration properties

This library generates and consumes RabbitMQ configurations for your consumers. Each consumer entry contains the following properties:

  • amqp: Name of the AMQP connection profile to use (e.g., default, users).
  • name: Human/unique identifier for the consumer, typically FQCN::method.
  • routing_key: List of routing keys the queue is bound to (e.g., sample_event).
  • unique: Whether this consumer definition should be treated as non-duplicated across generation/deployment.
  • url: HTTP route that maps to a controller endpoint for this consumer.
  • queue: Name of the queue to consume from (created/bound according to params when create_queue is true).
  • exchange: Exchange name to bind the queue to (e.g., teamsquad.event_bus).
  • function: Method on the consumer class that will be invoked for each message.
  • create_queue: If true, the queue will be declared/created automatically when setting up the consumer.
  • workers: Number of worker processes/consumers to spawn for this consumer (parallelism level).
  • params: RabbitMQ queue declaration parameters used when creating/declaring the queue:
    • passive: If true, do not create; only check that the queue exists.
    • durable: If true, the queue will survive a broker restart.
    • exclusive: If true, the queue is restricted to this connection and will be deleted when the connection closes.
    • auto_delete: If true, the queue will be deleted when the last consumer unsubscribes.
    • nowait: If true, do not wait for a server response to the declare/bind operation.
    • args: Additional arguments for the queue declaration:
      • x-expires (type: int): Message expires (auto-deletes) after this many milliseconds of inactivity.
      • x-ha-policy (type: string): High-availability policy (e.g., all) for classic mirrored queues (legacy RabbitMQ).

Example configuration (high throughput):

[
    'amqp'         => 'default',
    'name'         => 'TeamSquad\Tests\SampleConsumerWithWorkers::listenSampleHighThroughputEvent',
    'routing_key'  => ['high_throughput_event'],
    'unique'       => false,
    'url'          => '/_/tests-sampleconsumerwithworkers',
    'queue'        => 'high.throughput.queue',
    'exchange'     => 'teamsquad.event_bus',
    'function'     => 'listenSampleHighThroughputEvent',
    'create_queue' => true,
    'workers'      => 10,
    'params'       => [
        'passive'     => false,
        'durable'     => false,
        'exclusive'   => false,
        'auto_delete' => false,
        'nowait'      => false,
        'args'        => [
            'x-expires'   => ['type' => 'int', 'val' => 300000],
            'x-ha-policy' => ['type' => 'string', 'val' => 'all'],
        ],
    ],
]

teamsquad.io/php-event-bus 适用场景与选型建议

teamsquad.io/php-event-bus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.86k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 08 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 teamsquad.io/php-event-bus 我们能提供哪些服务?
定制开发 / 二次开发

基于 teamsquad.io/php-event-bus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 10.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2022-08-31