What's a good way to throw and handle events in PHP?
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 t开发者_Go百科o 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!
In my point of view, HTTP events could or must be handle in a Controller layer type. Your domain/application/core/whatever name you call your domain rules MUST not depend of Sessions, Requests (post, get) and etc.
Model must be decoupled from any interface/controller dependencies i.e: buttons form names, interfaces process and so on.
精彩评论