PHP code example of artisan-build / parfait

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

    

artisan-build / parfait example snippets


use ArtisanBuild\Parfait\Components\Panel;
use ArtisanBuild\Parfait\Components\Text;
use ArtisanBuild\Parfait\Enums\Color;
use ArtisanBuild\Parfait\Support\Container;

$panel = Panel::make('welcome')
    ->bordered()
    ->title('Parfait')
    ->body(Text::make('greeting', 'Welcome to the TUI!')->fg(Color::Cyan))
    ->setContainer(new Container(width: 40, height: 5));

echo $panel->render();

use ArtisanBuild\Parfait\Components\Panel;
use ArtisanBuild\Parfait\Components\Text;
use ArtisanBuild\Parfait\Layouts\Layout;
use ArtisanBuild\Parfait\Support\Container;

$ui = Layout::columns(1, 3)            // sidebar : main = 1 : 3
    ->add(Panel::make('sidebar')->sidebar()->title('Files'))
    ->add(Panel::make('main')->bordered()->body(Text::make('body', 'Editor')))
    ->setContainer(new Container(width: 100, height: 30));

echo $ui->render();

use ArtisanBuild\Parfait\Components\Text;
use ArtisanBuild\Parfait\Enums\Color;

it('styles text', function () {
    expect(Text::make('t', 'hi')->fg(Color::Cyan)->render())
        ->toBe("\e[38;5;81mhi\e[0m");
});