The EventDispatcher component provides tools that allow your application components to communicate with each other by dispatching events and listening to them. Object-oriented code has gone a long way to ensuring code extensibility. By creating classes that have well-defined responsibilities, your code becomes more flexible and a developer can extend them with subclasses to modify their behaviors. But if they want to share the changes with other developers who have also made their own subclasses, code inheritance is no longer the answer. Consider the real-world example where you want to provide a plugin system for your project. A plugin should be able to add methods, or do something before or after a method is executed, without interfering with other plugins. This is not an easy problem to solve with single inheritance, and even if multiple inheritance was possible with PHP, it comes with its own drawbacks.

Features

  • EventDispatcher component implements the Mediator and Observer design patterns to make all these things possible and to make your projects truly extensible
  • When an event is dispatched, it’s identified by a unique name (e.g. kernel.response), which any number of listeners might be listening to
  • When the dispatcher notifies listeners, it passes an actual Event object to those listeners
  • The base Event class contains a method for stopping event propagation
  • The dispatcher is the central object of the event dispatcher system
  • When an event is dispatched via the dispatcher, it notifies all listeners registered with that event

Project Samples

Project Activity

See All Activity >

Categories

Communications

License

MIT License

Follow EventDispatcher Component

EventDispatcher Component Web Site

Other Useful Business Software
Gemini 3 and 200+ AI Models on One Platform Icon
Gemini 3 and 200+ AI Models on One Platform

Access Google's best plus Claude, Llama, and Gemma. Fine-tune and deploy from one console.

Build generative AI apps with Vertex AI Studio. Switch between models without switching platforms.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of EventDispatcher Component!

Additional Project Details

Programming Language

PHP

Related Categories

PHP Communications Software

Registered

2021-07-20