2017 © Pedro Peláez
 

library events

Events oriented programming for PHP.

image

phower/events

Events oriented programming for PHP.

  • Friday, April 21, 2017
  • by pedrobrazao
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Phower Events

Events oriented programming for PHP., (*1)

Requirements

Phower Events requires:, (*2)

Instalation

Add Phower Events to any PHP project using Composer:, (*3)

composer require phower/events

Usage

This package provides an event-oriented mechanism which allows any PHP application to implement a way for separated parts to communicate with each other by dispatching events and listening to them., (*4)

An implementation of PhowerEvents requires an EventHandler class and at least an event listener which must be any valud PHP callable:, (*5)

use Phower\Events\EventHandlerInterface;
use Phower\Events\EventInterface;

class MyEventListener
{
    public onDummyEvent(EventInterface $event, EventHandlerInterface $handler)
    {
        print_r($event->getName());
        print_r($handler->getListeners($event));
    }
}

Note that any listener method should always expect two arguments: 1. An instance of EventInterface, representing the event triggered; 2. An intance of EventHandlerInterface, the handler which have triggered that event., (*6)

Before being able to trigger the listner above we must to attach it to an handler instance:, (*7)

use Phower\Events\EventHandler;

$handler = new EventHandler();
$handler->addListener('dummy', 'MyEventListener::onDummyEvent');

// later at any point where the handler is available:
$handler->trigger('dummy');

Container aware handlers

When a Container is part of an application it may be useful to automatically pass it across the listeners., (*8)

For this situation we can switch to an instance of ContainerAwareEventHandlerInterface and make our listeners also instances of ContainerAwareInterface., (*9)

Running Tests

Tests are available in a separated namespace and can run with PHPUnit in the command line:, (*10)

vendor/bin/phpunit

Coding Standards

Phower code is written under PSR-2 coding style standard. To enforce that CodeSniffer tools are also provided and can run as:, (*11)

vendor/bin/phpcs

Reporting Issues

In case you find issues with this code please open a ticket in Github Issues at https://github.com/phower/container/issues., (*12)

Contributors

Open Source is made of contribuition. If you want to contribute to Phower please follow these steps:, (*13)

  1. Fork latest version into your own repository.
  2. Write your changes or additions and commit them.
  3. Follow PSR-2 coding style standard.
  4. Make sure you have unit tests with full coverage to your changes.
  5. Go to Github Pull Requests at https://github.com/phower/container/pulls and create a new request.

Thank you!, (*14)

Changes and Versioning

All relevant changes on this code are logged in a separated log file., (*15)

Version numbers follow recommendations from Semantic Versioning., (*16)

License

Phower code is maintained under The MIT License., (*17)

The Versions

21/04 2017

dev-master

9999999-dev

Events oriented programming for PHP.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Pedro Ferreira

php events phower

12/04 2017

1.1.0

1.1.0.0

Events oriented programming for PHP.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Pedro Ferreira

php events phower

08/04 2017

1.0.0

1.0.0.0

Events oriented programming for PHP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

by Avatar Pedro Ferreira

php events phower