wpdiggerstudio/wpzylos-events 问题修复 & 功能扩展

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

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

wpdiggerstudio/wpzylos-events

最新稳定版本:v1.0.0

Composer 安装命令:

composer require wpdiggerstudio/wpzylos-events

包简介

PSR-14 compliant event dispatcher for WPZylos framework

README 文档

README

PHP Version License GitHub

PSR-14 compliant event dispatcher for WPZylos framework.

📖 Full Documentation | 🐛 Report Issues

✨ Features

  • PSR-14 Compliant — Standard event dispatcher interface
  • Event Classes — Type-safe event objects
  • Listeners — Single event handlers
  • Subscribers — Multi-event handlers
  • Stoppable Events — Control event propagation
  • Queued Events — Async event processing

📋 Requirements

Requirement Version
PHP ^8.0

🚀 Installation

composer require wpdiggerstudio/wpzylos-events

📖 Quick Start

use WPZylos\Framework\Events\EventDispatcher;

$dispatcher = new EventDispatcher();

// Register listener
$dispatcher->listen(UserCreated::class, function (UserCreated $event) {
    // Handle event
});

// Dispatch event
$dispatcher->dispatch(new UserCreated($user));

🏗️ Core Features

Event Classes

class UserCreated
{
    public function __construct(
        public readonly User $user
    ) {}
}

class OrderPlaced
{
    public function __construct(
        public readonly Order $order,
        public readonly User $customer
    ) {}
}

Listeners

// Closure listener
$dispatcher->listen(UserCreated::class, function (UserCreated $event) {
    mail($event->user->email, 'Welcome!', 'Thanks for signing up.');
});

// Class listener
$dispatcher->listen(UserCreated::class, [SendWelcomeEmail::class, 'handle']);

Subscribers

class UserEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            UserCreated::class => 'onUserCreated',
            UserDeleted::class => 'onUserDeleted',
        ];
    }

    public function onUserCreated(UserCreated $event): void
    {
        // Handle creation
    }

    public function onUserDeleted(UserDeleted $event): void
    {
        // Handle deletion
    }
}

$dispatcher->addSubscriber(new UserEventSubscriber());

Stoppable Events

class ValidatableEvent implements StoppableEventInterface
{
    private bool $propagationStopped = false;

    public function stopPropagation(): void
    {
        $this->propagationStopped = true;
    }

    public function isPropagationStopped(): bool
    {
        return $this->propagationStopped;
    }
}

📦 Related Packages

Package Description
wpzylos-core Application foundation
wpzylos-hooks WordPress hooks
wpzylos-scaffold Plugin template

📖 Documentation

For comprehensive documentation, tutorials, and API reference, visit wpzylos.com.

☕ Support the Project

If you find this package helpful, consider buying me a coffee! Your support helps maintain and improve the WPZylos ecosystem.

Donate with PayPal

📄 License

MIT License. See LICENSE for details.

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Made with ❤️ by WPDiggerStudio

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固