2017 © Pedro Peláez
 

library event

image

mhndev/event

  • Tuesday, October 3, 2017
  • by majidphpdeveloper
  • Repository
  • 2 Watchers
  • 3 Stars
  • 274 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

About

This is a really simple and lightweight php package for developing event based software, (*1)

Installation

composer require mhndev/event

Sample Usage

bind an closure to an event


Event::bind('order.payed',function($order){ //do some cool stuf here });

Another example

class MyClass {
    public function __invoke($order) {
        //do something here
    }
}

$myObject = new MyClass;


Event::bind('order.payed', $myObject($order));


trigger an event


// pass $order object as second argument Event::trigger('order.payed', $order);

Entity ( Model ) Observer

Binding an observer for a specific event on a model., (*2)


User::addObserver('before_update', function($driver){ });

Firing an Event on a model object., (*3)

Active Record Pattern, (*4)

class User
{
    use \mhndev\event\ObservableTrait;


    function update(array $data)
    {
        $user = $this;

        $this->fireEvent('before_update', $this);

        $updatedUser = $this->update($array);

        $driver->fireEvent('after_update', $user, $updatedUser);
    }
}


Data Mapper Pattern, (*5)


class User { use \mhndev\event\ObservableTrait; } class UserRepository { function update($user_identifier, array $data) { $user = $this->findByIdentifier($user_identifier); $user->buildByOptions($data); $user->fireEvent('before_update', $user); $updatedUser = $this->update($user); $driver->fireEvent('after_update', $user, $updatedUser); return $updatedUser; } }

Todos

-implement tests, (*6)

The Versions

03/10 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

03/10 2017

1.2.2

1.2.2.0

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

03/10 2017

dev-develop

dev-develop

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

02/08 2017

1.2.1

1.2.1.0

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

02/08 2017

1.2.0

1.2.0.0

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

28/05 2017

1.1.0

1.1.0.0

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

22/11 2016

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

19/11 2016

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event

09/07 2016

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

php event event based event oriented php event trigger event bind event