PHP code example of bitforge / thorm

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

    

bitforge / thorm example snippets



use Thorm\BuildExample;
use Thorm\Render;
use function Thorm\{state, el, text, attrs, cls, on, inc, read, client};

$cnt = state(0);
$app = el('div', [cls('p-3')], [
    el('h1', [], [text('Counter')]),
    el('p', [], [text(read($cnt))]),
    el('button', [attrs(['class' => 'btn btn-primary']), on('click', inc($cnt, 1))], [text('Increment')]),
]);

$app = client($app);

$render = new Render();
$res = $render->render($app);

BuildExample::build([
    'name' => 'counter',
    'path' => __DIR__ . '/public/examples/',
    'renderer' => $res,
    'template' => __DIR__ . '/assets/index.tpl.html',
    'opts' => [
        'title' => 'Counter',
        'containerId' => 'app',
    ],
]);
bash
php examples/counter.php