What is event-driven programming in PHP?
Why Interviewers Ask This
Interviewers ask this to evaluate whether you have the depth of knowledge needed to mentor others and lead technical decisions. The expected answer goes beyond definitions into practical implications and real-world consequences.
Answer
Event-driven programming decouples the code that detects something happening (event dispatcher) from the code that handles it (event listeners). In PHP, PSR-14 defines the standard EventDispatcherInterface. In Laravel: fire an event with event(new UserRegistered($user)) and listen with class SendWelcomeEmail { public function handle(UserRegistered $event) { ... } }. Symfony's EventDispatcher is the reference implementation. Benefits: open for extension (add listeners without touching the dispatching code), decoupled code (listener does not know about the dispatcher's context), and multiple listeners can react to the same event. Long-running PHP processes use event loops (ReactPHP, Amp) to handle I/O events asynchronously.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last PHP project, I used this when...' immediately makes your answer more credible and memorable.
Previous
What is middleware in PHP frameworks?
Next
What is Command Query Responsibility Segregation (CQRS) in PHP?