PHP code example of nawawishkid / ui-factory

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

    

nawawishkid / ui-factory example snippets




namespace BootstrapUI;

use UIFactory\Component;

class Button extends Component
{
    public function markup($props) : string
    {
        return '<button class="btn btn-primary">Click me!</button>';
    }
}

function button() {
    return '<button class="btn btn-primary">Click me!</button>';
}

class Button extends Component
{
    private $props = [
        'label' => 'Click me!'
        'class' => 'btn btn-primary'
    ];

    public function markup($props) : string
    {
        return (
<<<HTML
<button class="$props->class">
    $props->label
</button>
HTML
        );
    }
}



use BootstrapUI\Button;

$button = new Button();



use UIFactory\Components\Base;

$button = new Base();
$button->addProps([
            'label' => 'Click me!',
            'class' => 'btn btn-primary'
        ])
        ->addMarkup(function($props) {
            return "<button class=\"$props->class\">$props->label</button>";
        })
        ->render();



use BootstrapUI\Button;

$btn = new Button([], 0);
$btn->render(); // default

$btn->editProps([
        'label' => "Don't click me!",
        'class' => 'btn-dont-click'
    ])
    ->render();