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

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

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

caridea/event

最新稳定版本:3.0.0

Composer 安装命令:

composer require caridea/event

包简介

A shrimp of an event library

README 文档

README

Caridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework.

This is its event library. It has interfaces for Publisher and Listener, and an abstract class for Event.

If you'd like a concrete implementation of Publisher, try caridea-container.

Packagist Build Status Scrutinizer Code Quality Code Coverage

Installation

You can install this library using Composer:

$ composer require caridea/event
  • The master branch (version 3.x) of this project requires PHP 7.1 and has no dependencies.
  • Version 2.x of this project requires PHP 7.0 and has no dependencies.
  • Version 1.x of this project requires PHP 5.5 and has no dependencies.

Compliance

Releases of this library will conform to Semantic Versioning.

Our code is intended to comply with PSR-1, PSR-2, and PSR-4. If you find any issues related to standards compliance, please send a pull request!

Documentation

Examples

Just a few quick examples.

Let's say you have defined these classes

namespace Acme\Foo;

class CustomEvent extends \Caridea\Event\Event
{
}

class CustomEventListener implements \Caridea\Event\Listener
{
    public function notify(\Caridea\Event\Event $event)
    {
        if ($event instanceof CustomEvent) {
            // do something here
        }
    }
}

A publisher can be invoked like this:

// Here, we assume that $publisher implements a \Caridea\Event\Publisher and that
// We have somehow registered an \Acme\Foo\CustomEventListener with it.
$publisher->publish(new \Acme\Foo\CustomEvent());
// Our CustomEventListener has its ->notify method invoked.

There's a no-op implementation of Publisher available as \Caridea\Event\NullPublisher.

PublisherAware

For classes which need the event publisher, you can make use of the PublisherAware interface, and optionally the PublisherSetter trait.

class MyClass implements \Caridea\Event\PublisherAware
{
    use \Caridea\Event\PublisherSetter;

    public function __construct()
    {
        $this->setPublisher(new \Caridea\Event\NullPublisher());
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-06-03