1. Go to this page and download the library: Download aatis/event-dispatcher 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/ */
aatis / event-dispatcher example snippets
use Aatis\EventDispatcher\Event\Event;
class ExampleEvent extends Event
{
}
use Aatis\EventDispatcher\Event\StoppableEvent;
class ExampleStoppableEvent extends StoppableEvent
{
}
class ExampleListener
{
public function __invoke(ExampleEvent $event): void
{
// Do something
}
}
#[EventListener(priority: 2)]
class ExampleListener
{
public function __invoke(ExampleEvent $event): void
{
// Do something
}
}
class TestSubscriber implements EventSubscriberInterface
{
public function onExample(Event $event): void
{
// Do something
}
public function onExampleBis(Event $event): void
{
// Do something
}
public function getSubscribedEvents(): iterable
{
return [
ExampleEvent::class => 'onExample',
ExampleBisEvent::class => 'onExampleBis',
];
}
}
public function getSubscribedEvents(): iterable
{
return [
ExampleEvent::class => [
'onExample',
'onExampleBis'
],
ExampleBisEvent::class => 'onExampleBis',
];
}
public function getSubscribedEvents(): iterable
{
return [
ExampleEvent::class => [
['onExample', 2],
'onExampleBis'
],
ExampleBisEvent::class => ['onExampleBis', 2],
];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.