PHP code example of drevops / phptui

1. Go to this page and download the library: Download drevops/phptui 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/ */

    

drevops / phptui example snippets


use DrevOps\PhpTui\Builder\Form;
use DrevOps\PhpTui\Builder\PanelBuilder;
use DrevOps\PhpTui\Tui;

$form = Form::create('Quick start')
  // Every block is declared by the label it draws, and the id it answers to is
  // derived from that label: "Order name" collects into "order_name". Declare
  // an id after the label - $p->text('Order name', 'name') - when it has to be
  // a particular string.
  ->panel('New order', function (PanelBuilder $p): void {
    // A ger bounded to a sensible quantity.
    $p->number('Quantity')->min(1)->max(99)->default(6);

    // A yes/no gate.
    $p->confirm('Organic only?')->default(FALSE);
  });

$tui = new Tui($form, handler_namespaces: ['App\\Handler']);

$answers = $tui->run();

$tui = (new Tui($form))->theme('midnight');