I am learning how to use Zend framework and realise that the action helper is something that would be useful.
I have set up a default installation of Zend on my machine, but I dont know where the helper file needs to go, what I need to put in the bootstrap file and how I use it. Can anyone point me in the right direction please – the ZF user guide is not to clear to me.
Thanks
John
Two thoughts for where to place your custom action-helpers:
application/controllers/helpersThese ideas are not exclusive. Functionality that is general enough to work in multiple projects should probably be pulled into a separate library. But for functionality that is application-specific, there is an argument that it could be somewhere in the
applicationfolder.@Jurian has already described the “separate-library” approach. For app-specific helpers, you can do as follows:
For a helper called myHelper, create a class
Application_Controller_Helper_MyHelperin the fileapplication/controllers/helpers/MyHelper.php. InBootstrap, you have something like:Then your helper can be invoked in a controller by using:
As you can see, this presumes you are using appNamespace ‘Application’. If not, you can (must!) modify your class names to accommodate your circumstance.
Cheers!