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

Master Zend Framework:
How to Simplify Expressive Configuration with Interop-Config
Nov 17, 2016 @ 15:58:59

On the Master Zend Framework site there's a tutorial posted showing you how to simplify your Zend Expressive configuration with the help of the interop-config package.

Zend Expressive (and Zend Framework) are great frameworks, ones designed not to constrain you in almost any way. You’re in charge. You set the scene. You make it do just what you want it to do. Unlike other frameworks, you’re not bound to work with a specific way. You’re free to work in, almost, whatever way you want. But that comes at a price.

Consequently, using Zend Expressive can give you too much freedom — especially when it comes to configuration. That’s why I was happy to hear about Interop-Config some time ago from my friend Sandro Keil.

Interop-Config is a library which helps ensure that you have a valid configuration for your code. It can provide default options, as well as enforce mandatory options, ensuring that it has a well laid out structure, and is easy to understand.

He starts by briefly talking about the package itself and what kinds of features it brings along with it. The tutorial then shows how to get the package installed and a simple base configuration. With that in place it then shows you how to access this configuration via the "ConfigurationTrait" and a "dimensions" method. From there you can then easily get configuration data from the DI container (and see if it exists with a "canRetrieveOptions" method). The post finishes up showing you how to add default values, making options mandatory and a bit about defensive programming methodologies in using the tool.

tagged: zendexpressive configuration interopconfig package tutorial zendframework

Link: http://www.masterzendframework.com/simplify-expressive-configuration-with-interop-config/


Trending Topics: