PHP code example of hguenot / html-builder

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

    

hguenot / html-builder example snippets


function generateBarcodeHtml( $barcode ) {
	
	$generator = new BarcodeGeneratorHTML();
	$htmlCode = $generator->getBarcode( $$barcode->toString(), $$barcode->getType(), 1, 45 );
	
	$el = Html::element('div');
	$el->addClass('barcode-container');
	
	Html::element('div')
		->addClass('barcode-bars')
		->html( $htmlCode )
		->appendTo($el);
	
	Html::element('div')
		->addClass('barcode-number')
		->text( $normalizedValue->toString() )
		->appendTo($el);
	
	return $el;
}

public function generateMenu(array $items) {
	
	$ul = Html::element('ul');
	
	foreach ( $this->items as $item ) {

		$li = Html::element('li')
			->appendTo( $ul )
			->toggleClass('active', $item['id'] === $this->activeId);
		
		Html::element('a')
			->attr('href', '/' . $item['url_key'] . '.html')
			->text( $item['title'] )
			->appendTo( $li );
		
	}
	
	return (string)$ul;
}