O'Reilly logo

Zend Framework 2 Cookbook by Josephus Callaars

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing a custom view strategy/renderer

Nothing is more exciting in coding than developing your own bits of custom features that integrate with the framework. In this recipe we will be discussing how to create our own XML view strategy. We will show you how to simply create the basis for a new strategy without too much of a bother.

How to do it…

Sometimes the default strategies and renderers provided are not enough for a specific situation, so let's talk through on how to create our own view strategy/renderer.

Creating the XmlOutput renderer

Let us see first on how our renderer would look like, as that is possibly one of the laziest classes we will ever code. We will do this in a new class located in /module/XmlOutput/src/XmlOutput/View/Renderer/XmlRenderer.php ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required