PHP code example of vivait / symfony-console-promptable-options

1. Go to this page and download the library: Download vivait/symfony-console-promptable-options 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/ */

    

vivait / symfony-console-promptable-options example snippets


    protected function configure()
    {
        $this
            ->setName('promptable:test')
            ->addPrompts(
                [
                    'name', // No configuration provided - uses defaults
                    'age' => ['type' => 'int', '



use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Vivait\PromptableOptions\Command\PromptableOptionsTrait;

class PromptableCommand extends Command
{

    use PromptableOptionsTrait;

    protected function configure()
    {
        $this
            ->setName('promptable:demo')
            ->addPrompt(
                'name',
                ['description' => 'Your name', '               'name'       => ['description' => 'Your name', 'ln(sprintf('Hello %s!', $name));

        $age = $this->getConsoleOptionInput('age');

        if ($age) {
            $output->writeln(sprintf('You are %s years old', $age));
        }
        
        $occupation = $this->getConsoleOptionInput('occupation');
        $output->writeln(sprintf('You are a %s!', $occupation));
    }
}