PHP code example of grzegorz-jamroz / html-creator

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

    

grzegorz-jamroz / html-creator example snippets


use HtmlCreator\ContentBuilder;
use HtmlCreator\Helmet;
use HtmlCreator\PageBuilder;use HtmlCreator\PageFactory;

$data = [
    'seo' => [],
    'header' => 'Page title',
    'navbar' => [
        'items' => [
            [
                'name' => 'Home',
                'url' => '/home',
            ],
            [
                'name' => 'About',
                'url' => '/about',
            ],
            [
                'name' => 'Contact',
                'url' => '/contact',
            ],
        ],
    ],
    'sections' => [],
    'footer' => [
        'text' => 'Copyright ©'
    ],
];

$pageBuilder = new PageBuilder(
    'en',
    '/path/to/your/app.js',
    '/path/to/your/styles.css',
    Helmet::createFromArray($data['seo'] ??= []),
    ContentBuilder::createFromArray($data),
);
$html = (new PageFactory($pageBuilder))->getHtml();