platformsh / console-form
A lightweight Symfony Console form system.
Installs: 75 777
Dependents: 2
Suggesters: 0
Security: 0
Stars: 21
Watchers: 5
Forks: 4
Open Issues: 0
Requires
- php: ^8.2
- symfony/console: ^7.0 || ^6.0
Requires (Dev)
- phpunit/phpunit: ^11
- symplify/easy-coding-standard: ^12.3
- dev-master
- dev-main
- v1.0.0-beta1
- v0.0.37
- v0.0.36
- v0.0.35
- v0.0.34
- v0.0.33
- v0.0.32
- v0.0.31
- v0.0.30
- v0.0.29
- v0.0.28
- v0.0.27
- v0.0.26
- v0.0.25
- v0.0.24
- v0.0.23
- v0.0.22
- v0.0.21
- v0.0.20
- v0.0.19
- v0.0.18
- v0.0.17
- v0.0.16
- v0.0.15
- v0.0.14
- v0.0.13
- v0.0.12
- v0.0.11
- v0.0.10
- v0.0.9
- v0.0.8
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-php-8
- dev-conditional-field-error
This package is auto-updated.
Last update: 2024-11-25 23:28:30 UTC
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']); } }