Evan Coury has a new post today showing how to create a simple view helper in a Zend Framework 2 based application.
This post will show you how to create a simple view helper in Zend Framework 2. In this example, our view helper will simply return the full, absolute URL of the current page/request.
Code for the example is included, showing how to pull in the namespaced dependencies and extend the AbstractHelper to define the simple view helper. The "__invoke" method is used to handle the functionality and the configuration for the helper is defined in the Module's "getViewHelperConfig" options. You can find out more about the View Helpers in Zend Framework 2 in their manual page.