Code to run on class loading
Posted: Tue Mar 30, 2010 6:24 pm
Hey all -
I'm a veteran PHP programmer... I'm currently looking for a way to execute code when a class is defined.
Note that this isn't the same as when an object is instantiated; I know about __construct (and have committed some fun perversions with it). I'm looking for a hook or method I can use to execute code during or immediately after actual class definition, specifically to register classes that share a parent.
I could do this with an extra call or an instantiation following every definition of a subclass, but I'm hoping to avoid that, as I'd like this to be reusable and as simple as possible from the programmer's perspective. Has anyone managed anything like this in PHP?
Thanks!
I'm a veteran PHP programmer... I'm currently looking for a way to execute code when a class is defined.
Note that this isn't the same as when an object is instantiated; I know about __construct (and have committed some fun perversions with it). I'm looking for a hook or method I can use to execute code during or immediately after actual class definition, specifically to register classes that share a parent.
I could do this with an extra call or an instantiation following every definition of a subclass, but I'm hoping to avoid that, as I'd like this to be reusable and as simple as possible from the programmer's perspective. Has anyone managed anything like this in PHP?
Thanks!