PHP code example of mikemix / eventdispatcher

1. Go to this page and download the library: Download mikemix/eventdispatcher 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/ */

    

mikemix / eventdispatcher example snippets

 composer.phar self-update && php composer.phar update

return array(
    'event_dispatcher' => array(
        'dispatch' => array(
            // dispatch listeners here
            'myDispatchListener'       # <----------------- NOTICE
        ),
        'dispatch.error' => array(
            // dispatch.error listeners here
        ),
        'finish' => array(
            // finish listeners here
        ),
        'render' => array(
            // render listeners here
        ),
        'render.error' => array(
            // render.error listeners here
        ),
        'route' => array(
            // route listeners here
        ),
    ),
);

// ...
'service_manager' => array(
    // ...
    
    'invokables' => array(
        'myDispatchListener' => 'Application\Listener\DispatchListener',
    ),
),


namespace Application\Listener;

use EventDispatcher\Listener\ListenerInterface;

class DispatchListener implements ListenerInterface
{
    public function onEvent(EventInterface $event)
    {
        printf('Well hello, a %s event was called', $event->getName());
    }
}
application.config.php
vendor/mikemix/eventdispatcher/config/event_dispatcher.global.php.dist
config/autoload/event_dispatcher.global.php
event_dispatcher.global.php
config/autoload/event_dispatcher.config.php
module/Application/config/module.config.php
module/Application/src/Application/Listener/DispatchListener.php