I have to agree with Matthew. A lot of ZF can seem like overkill at times, and obviously you only have to use what you want to, but Zend_Registry is a "good idea"

Using globals is how I used to do it, but over 10 years of PHP development I've found it to be a messy and, at times, dangerous technique.

By using an OO-approach you always know where your registry items come from, you can't overwrite them accidentally and you can throw exceptions if you try to access things that don't exist (whereas you just get a potentially unpredictable response if you just access an undefined global variable and then try to do things with it - the curse of PHP's loose typing!)

Also, if you ever have to join two different PHP apps together using globals can be truly nightmarish (i've done it, when two different apps have used the same global namespace variables).

In my opinion, if you keep everything separate using OO it keeps things organised, predictable and in the long term it's a lot simpler.

best wishes,
Si


Reply via email to