When you use $front->setParam , you define the parameter in Front Controller.
But this option is not available (or should not be used) by other layers of the application, for example Model.
Zend_Registry , like any other global variable, is accessible from anywhere in your application, including inside the model.
But using the registry instead of a combination of global variables ensures that you will not have many global variables everywhere: even if using the registry implies some kind of global state (which is not so good, I must say), it is better to have everything in one place.
A few examples of real life might be:
- Save the database connection that is installed in bootsreap but is used in models
- Store globally the adapter (or any mechanism) that will be used for translation / localization in all layers of your application. Zend Framework itself does this.
In the end, can I find Zend_Registry useful?
Well, when it comes to having some global state, yes, it is helpful.
But if this can be avoided, it could be better: conceptually speaking, no better than your classes depending on any global state: easier to reuse, easier to test ...
You may want to take a look at what Injection of Dependency is about this .
Pascal martin
source share