PHP Classes

File: examples/bootstrap.php

Recommend this page to a friend!
  Classes of Temuri Takalandze   PHP HTML Generator Library   examples/bootstrap.php   Download  
File: examples/bootstrap.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP HTML Generator Library
Compose and generate HTML programatically
Author: By
Last change:
Date: 3 years ago
Size: 1,875 bytes
 

Contents

Class file image Download
<?php

// Include Composer Autoloader.
require_once __DIR__ . '/../vendor/autoload.php';

use
ABGEO\HTMLGenerator\Document;
use
ABGEO\HTMLGenerator\Element;
use
ABGEO\HTMLGenerator\Exception\InvalidDocumentException;

$document = new Document();
$element = new Element();

try {
   
$container = Element::createDiv(
       
Element::createDiv(
           
Element::createDiv(
               
Element::concatenateElements(
                   
Element::createHeading('Hello, World!', 1, ['mt-5']),
                   
Element::createParagraph(
                       
'This is simple Bootstrap 4 page', ['lead']
                    ),
                   
Element::createList(
                        [
                           
Element::concatenateElements(
                               
'Generated By ',
                               
Element::createLink(
                                   
'gen-html',
                                   
'https://github.com/ABGEO07/gen-html/commits/master',
                                   
Element::TARGET_BLANK
                               
), '.'
                           
)
                        ],
Element::LIST_UNORDERED, ['list-unstyled']
                    )
                ),
                [
'col-lg-12', 'text-center']
            ),
            [
'row']
        ),
        [
'container']
    );

   
$document
       
->setTitle('Title')
        ->
addStyle('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css')
        ->
setBody($container)
        ->
addScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js')
        ->
addScript('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js');

    echo
$document->getDocument();
} catch (
InvalidDocumentException $e) {
    die(
$e->getMessage());
} catch (
ReflectionException $e) {
    die(
$e->getMessage());
}