The Framework PHP Helpers



Examples of PHP Helper class: "HelperDiv"

DOWNLOAD version 0.1.0
released at 2018-02-25 19:50 GMT

  1. Download Helpers (zip file)
  2. Unzip it in your vendors folder (e.g)
  3. Include autoload.php in your bootstrap file
    <?php
    /*
    lets suposse you have this folder tree
        yourproject/
            vendors/
                lib_1/
                lib_n/
                theframework/   -->uncompressed zip
                    helpers/
            index.php
    */
    //this file is: yourproject/index.php
    include_once("vendors/theframework/helpers/autoload.php");
    
    use TheFramework\Helpers\HelperInputText;
    $oInput = new HelperInputText();
    $oInput->set_value("Hello World");
    $oInput->add_class("form-control");
    $oInput->show();
  4. Result: Example of HelperInputText



Resume

It helps to create html element "div":
<div>...innerhtml...</div>

Examples:


Example 1


Live Html

1 of 2
2 of 2

PHP Code:

<?php
use TheFramework\Helpers\HelperDiv;
$oDivCell = new HelperDiv("1 of 2");
$oDivCell->add_class("col");
$oDivCell2 = new HelperDiv("2 of 2");
$oDivCell2->add_class("col");

$oDivRow = new HelperDiv();
$oDivRow->add_class("row");
$oDivRow->add_inner_object($oDivCell);
$oDivRow->add_inner_object($oDivCell2);

$oDivContainer = new HelperDiv();
$oDivContainer->add_class("container");
$oDivContainer->add_inner_object($oDivRow);
$oDivContainer->show();
?>

HTML Result:

<div class="container">
<div class="row">
<div class="col">
1 of 2</div>
<div class="col">
2 of 2</div>
</div>
</div>

Example 2


Live Html

1 of 3
Variable width content
3 of 3
1 of 3
Variable width content
3 of 3

PHP Code:

<?php
$oDivCell = new HelperDiv("1 of 3");
$oDivCell->add_class("col col-lg-2");
$oDivCell->add_style("border:1px solid #ccc");
$oDivCell2 = new HelperDiv("Variable width content");
$oDivCell2->add_class("col");
$oDivCell2->add_style("border:1px solid #ccc");
$oDivCell3 = new HelperDiv("3 of 3");
$oDivCell3->add_class("col col-lg-2");
$oDivCell3->add_style("border:1px solid #ccc");

$oDivRow = new HelperDiv();
$oDivRow->add_class("row justify-content-md-center");
$oDivRow->add_inner_object($oDivCell);
$oDivRow->add_inner_object($oDivCell2);
$oDivRow->add_inner_object($oDivCell3);

$oDivRow2 = new HelperDiv();
$oDivRow2->add_class("row");
$oDivCell = new HelperDiv("1 of 3");
$oDivCell->add_class("col");
$oDivCell->add_style("border:1px solid #ccc");
$oDivCell2 = new HelperDiv("Variable width content");
$oDivCell2->add_class("col-12 col-md-auto");
$oDivCell2->add_style("border:1px solid #ccc");
$oDivCell3 = new HelperDiv("3 of 3");
$oDivCell3->add_class("col col-lg-2");
$oDivCell3->add_style("border:1px solid #ccc");
$oDivRow2->add_inner_object($oDivCell);
$oDivRow2->add_inner_object($oDivCell2);
$oDivRow2->add_inner_object($oDivCell3);

$oDivContainer = new HelperDiv();
$oDivContainer->add_class("container");
$oDivContainer->add_inner_object($oDivRow);
$oDivContainer->add_inner_object($oDivRow2);
$oDivContainer->show();
?>

HTML Result:

<div class="container">
<div class="row justify-content-md-center">
<div class="col col-lg-2" style="border:1px solid #ccc">
1 of 3</div>
<div class="col" style="border:1px solid #ccc">
Variable width content</div>
<div class="col col-lg-2" style="border:1px solid #ccc">
3 of 3</div>
</div>
<div class="row">
<div class="col" style="border:1px solid #ccc">
1 of 3</div>
<div class="col-12 col-md-auto" style="border:1px solid #ccc">
Variable width content</div>
<div class="col col-lg-2" style="border:1px solid #ccc">
3 of 3</div>
</div>
</div>