1. Go to this page and download the library: Download platformsh/console-form library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
platformsh / console-form example snippets
namespace MyApplication;
use Platformsh\ConsoleForm\Field\EmailAddressField;
use Platformsh\ConsoleForm\Field\Field;
use Platformsh\ConsoleForm\Form;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MyCommand extends Command
{
protected function configure()
{
$this->setName('my:command')
->setDescription('An example command');
$this->form = Form::fromArray([
'name' => new Field('Name', ['description' => 'Your full name']),
'mail' => new EmailAddressField('Email', ['description' => 'Your email address']),
]);
$this->form->configureInputDefinition($this->getDefinition());
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$questionHelper = $this->getHelper('question');
$result = $this->form->resolveOptions($input, $output, $questionHelper);
$output->writeln("Your name: " . $result['name']);
$output->writeln("Your email address: " . $result['mail']);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.