1. Go to this page and download the library: Download radnan/rdn-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/ */
radnan / rdn-event example snippets
return array(
'modules' => array(
'RdnEvent',
// ...
),
);
~~~
## How to use
Simply configure your event listeners with the `RdnEvent\Listener\ListenerManager` service locator using the `rdn_event_listeners` configuration option. Listeners are any class that implements the `Zend\EventManager\ListenerAggregateInterface` interface.
~~~php
return array(
'rdn_event_listeners' => array(
'invokables' => array(),
'factories' => array(),
),
);
~~~
## How to create listeners
Create your listeners inside your module, register them with the event listener service locator, and finally attach the listener by including it in the `rdn_event[listeners]` configuration option.
Let's create a hello world listener inside our `App` module:
### 1. Create listener class
Create the class `App\Listener\HelloWorld` by extending `RdnEvent\Listener\AbstractListener`:
~~~php
namespace App\Listener;
use RdnConsole\Listener\AbstractListener;
use Zend\EventManager\EventInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\Mvc\MvcEvent;
class HelloWorld extends AbstractListener
{
public function attach(EventManagerInterface $events)
{
$this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'execute'));
}
public function execute(EventInterface $event)
{
var_dump('Hello World!');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.