PHP code example of caridea / event

1. Go to this page and download the library: Download caridea/event library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

caridea / event example snippets


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
        }
    }
}

// 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.

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

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