ZendFramework 2 - Create a custom view helper
For many situations, we need some helper functions to be used in view.
i.e. When you want to debug, probably you will write
<pre> to wrap it will be more readable, unfortunately you don’t want to every time write such a long line. Now, create a helper to be able to use in all views.
Create a new file ./module/Application/src/Application/View/Helper/God.php (Let’s call it
God as this helper can do anything that you want provided you defined it as a function inside)
Now you have to edit your ./module/Application/Module.php in order for it to load to view
godHelper is an alias to be used in your view.
Now you’re done, you can use in any view now. i.e.
You can now add as many functions as you want to the