Lab 13: Event-Driven PHP
Step 1: PSR-14 Interfaces
<?php
// PSR-14 interfaces (simplified β use psr/event-dispatcher in real projects)
interface StoppableEventInterface {
public function isPropagationStopped(): bool;
}
interface ListenerProviderInterface {
public function getListenersForEvent(object $event): iterable;
}
interface EventDispatcherInterface {
public function dispatch(object $event): object;
}
// Verify interfaces
echo "PSR-14 interfaces defined\n";
$interfaces = ['StoppableEventInterface', 'ListenerProviderInterface', 'EventDispatcherInterface'];
foreach ($interfaces as $iface) {
echo " β $iface\n";
}Step 2: Implementing a PSR-14 Dispatcher
Step 3: Stoppable Events
Step 4: Event Subscribers
Step 5: Async Event Handling Concept
Step 6: Symfony Messenger Concepts
Step 7: Event Middleware Pipeline
Step 8: Capstone β Full Event System
Summary
Concept
Interface/Class
PSR
Last updated
