platformsh/console-form
最新稳定版本:v1.0.0-beta1
Composer 安装命令:
composer require platformsh/console-form
包简介
A lightweight Symfony Console form system.
README 文档
README
A lightweight form system for Symfony Console commands.
Commands can define forms which can be used both via command-line options and via interactive input.
Example
<?php 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']); } }
Alternatives
统计信息
- 总下载量: 79.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-29