Google News
logo
Zend framework - Interview Questions
What about Console prompts in Zend framework?
In addition to console abstraction layer Zend Framework 2 provides numerous convenience classes for interacting with the user in console environment. This chapter describes available Zend\Console\Prompt classes and their example usage.
 
All prompts can be instantiated as objects and provide show() method.
use Zend\Console\Prompt;

$confirm = new Prompt\Confirm('Are you sure you want to continue?');
$result = $confirm->show();
if ($result) {
    // the user chose to continue
}
 
There is also a shorter method of displaying prompts, using static prompt() method :
use Zend\Console\Prompt;

$result = Prompt\Confirm::prompt('Are you sure you want to continue?');
if ($result) {
    // the user chose to continue
}
Advertisement