switon/event 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

switon/event

Composer 安装命令:

composer require switon/event

包简介

Class-based synchronous PSR-14 dispatch with attribute-discovered listeners for Switon Framework

README 文档

README

CI PHP 8.3+

Switon's PSR-14 event package for application dispatch, listener discovery, and event logging.

Highlights

  • Wildcard listeners: one listener can handle every event with object.
  • Attribute-based listeners: #[EventListener] registers listener methods.
  • Automatic listener discovery: app scan paths and extra.switon.listeners entries are included.
  • Event log level: events can carry a default PSR-3 level.
  • Early-stop support: listeners can halt the remaining chain when needed.
  • Automatic event logging: events can be logged automatically with structured output.

Installation

composer require switon/event

Quick Start

use Psr\EventDispatcher\EventDispatcherInterface;
use Switon\Core\Attribute\Autowired;
use Switon\Eventing\Attribute\EventListener;

final class UserRegistered
{
    public function __construct(public int $userId, public string $email)
    {
    }
}

class UserService
{
    #[Autowired] protected EventDispatcherInterface $eventDispatcher;

    public function register(string $email): void
    {
        $this->eventDispatcher->dispatch(new UserRegistered(123, $email));
    }
}

class UserListener
{
    #[EventListener]
    public function onUserRegistered(UserRegistered $event): void
    {
        // react to the event
    }
}

Docs: https://docs.switon.dev/latest/event

License

MIT.

统计信息

  • 总下载量: 76
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 31
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固