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

Rob Allen:
Stand-alone usage of Zend-InputFilter
Feb 15, 2017 @ 09:58:51

Rob Allen has written up a brief tutorial showing you how to use the Zend/Filter component independently from a Zend Framework application. In his example he integrates it into a simple API endpoint.

Any data that you receive needs to be checked and validated. There are number of ways to do this including PHP's filter_var, but I prefer Zend-InputFilter. This is how to use it as a stand-alone component.

He shows you how to get the component installed (along with the Zend ServiceManager) and the creation of a basic validation/filtering on "author" data. He explains the different parts that make up the instance: required, filters and validators. He then shows how to use it in your request and the resulting output if something fails.

tagged: zendframework zendfilter component standalone usage tutorial

Link: https://akrabat.com/standalone-usage-of-zend-inputfilter/