What's a good way to throw and handle events in PHP?
Posted
by
techexpert
on Stack Overflow
See other posts from Stack Overflow
or by techexpert
Published on 2011-01-10T19:14:57Z
Indexed on
2011/01/13
9:53 UTC
Read the original article
Hit count: 219
php
|event-handling
Hi everyone,
I am just trying to get a general idea about the event prcessing mechanism in PHP5 in as neat way as possible. First of all I understand that a PHP application is not exactly a persistent type, so the events may not make a lot of sense, but from the OO perspective it might be a very elegant way to "communicate" between the objects.
So I am thinking that it would make sense to separate the events on the external events, such as $_POST
& $_GET
and the internal ones, i.e. function callbacks.
As far as the external ones, is it a good idea to process the $_GET
s and $_POST
s directly, or is it better to wrap them into an event of some sort?
Also, in order to process the internal events, do you have to pass the reference to the event handler/dispatcher to each class so they know how to throw them? I was thinking to use the PEAR EventDispatcher to do the work, but I am open to other suggestions.
Thank you!
© Stack Overflow or respective owner