News Feed
Sections




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

Odafe Ojenikoh's Blog:
Interactive PHP CLI Applications using Zend Form
February 16, 2012 @ 11:09:57

Odafe Ojenikoh has submitted a post he's written up showing how to create a command line PHP application with the help of the Zend Framework and it's Zend_Form elements.

Over the weekend, I was toying with the idea of interactive cli applications using readline() and Zend Form for validating input. My motivation for using Zend Form or rather Zend Form elements was to exploit the power of features such as labels, validators, filters and the prospect of reusing forms within web application code.

His example code defines a Filter for the form errors (returning them as a string) and a "Cli" class that handles the interaction with the command line. Next up is a class defining the form elements - a prompt for a color name and either of the words "thank" and "you". The Cli class transforms the form elements into prompts on the command line and lets you define validators to check their input.

0 comments voice your opinion now!
zendform zendframework cli commandline application tutorial


blog comments powered by Disqus

Similar Posts

Dave Dash's Blog: Finding things using Zend Search Lucene in symfony

Lorna Mitchell: Running Multiple Versions of PHP

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 5)

Stefan Mischook's Blog: Creating Your Own Functions - Part 2

Lorna Mitchell: Do Open Source with Git and Github


Community Events





Don't see your event here?
Let us know!


api list tips laravel language introduction framework podcast threedevsandamaybe community zendserver symfony code interview release deployment series voicesoftheelephpant conference bugfix

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework