Been looking at what Java and .NET do in regard to event handling in web applications.
To date, most PHP apps which get into OO use a fusebox like approach, in that one script (usually index.php) is used to handle events - all things begin with index.php. That’s fine but I’m wondering if there’s a more generic way to do it - a class you can simple instantiate from anywhere to handle events?
Some resources for Java and .NET that discuss this;
The way I see it in PHP is something like this;
An EventRegister class (using a Singleton pattern) which any object can use to register events with.
An EventHandler class, which checks _GET, _POST, _COOKIE and _FILE for events registered with the EventRegister class.
The next (tough) question is how the EventHandler can fire off the event itself (e.g. an object which validates incoming $_POST data then another object which INSERTs into a database).
Any ideas? My attempts at writing the classes so far have left me deeply confused.