Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Master Zend Framework:
How to Create a Zend Expressive Module
Jul 26, 2017 @ 16:14:52

On the Master Zend Framework site Matthew Setter has written up a tutorial showing you how to create a Zend Expressive module to help organize your application and keep related files all in one place.

I've been reflecting recently on the things that I commonly have to do when I begin building Zend Expressive applications. Of the list that I created, I found that one of the most common — and uninteresting — of them is setting up the rendering of static page content. [...] To solve this, I've usually manually created modules to handle the rendering of static page content. These module's usually had little more than a PageAction class that returned an HtmlResponse object, whose body was a rendered template file.

[...] If you're in a similar position to where I was and want to collate the logic into a reusable module, then follow along with me in this tutorial I'm going to step you through how to create a module which you can reuse across any Zend Expressive project.

He starts by briefly describing a "module" in the context of a Zend Expressive application and how they relate (or don't) to the modules in Zend Framework v2. He then starts in on the module creation, showing how to set up the environment, change the Composer configuration to autoload correctly and describes what the end result should look like. From there the tutorial starts on the code required for the classes covering the basics of the class, exception handling, configuration and the creation of a factory to make a module instance.

tagged: zendexpressive tutorial module static content zendframework

Link: http://www.masterzendframework.com/create-a-zend-expressive-module/


Trending Topics: