When you are using $front->setParam
, you are defining a parameter in the Front Controller.
But that parameter is not available in (or should not be used from) other layers of the application, such as the Model.
Zend_Registry
, like any other global variable, is available from anywhere in your application -- including inside the Model.
But using a Registry instead of a bunch of global variables ensures you won't have many global variables everywhere : even if using a Registry implies some global state (which is not that good, one should say), it's better to have that all in one place.
A couple of real life examples could be :
- Store the connection to the database, which is established in the bootsreap, but used in the Models
- Globally store an adapter (or any mecanism) that will be used to do translations / localisation in all layers of your application -- Zend Framework itself does that.
In the end, do I find Zend_Registry
useful ?
Well, when it comes to having some global state, yes, it's useful.
But if it's usage can be avoided, it might be better : conceptually speaking, not having your classes depend on any global state is better : easier to re-use, easier to test, ...
About that, you might want to take a look at what Dependency Injection is.