The Framework PHP Helpers



Examples of PHP Helper class: "HelperAnchor"

DOWNLOAD version version
released at [not found]

  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 allows you to create <a>...</a> html element

Examples:


Example 1


Live Html


PHP Code:

<?php
use TheFramework\Helpers\HelperAnchor;
use TheFramework\Helpers\HelperRaw;

$arHtml = [];
$arHtml[] = new HelperRaw("<ul class=\"nav nav-pills\">");
$arHtml[] = new HelperRaw("<li class=\"nav-item\">");
$arHtml["anchor_1"] = new HelperAnchor("Eduardoaf.com");
$arHtml["anchor_1"]->add_class("nav-link active");
$arHtml["anchor_1"]->set_href("http://eduardoaf.com");
$arHtml["anchor_1"]->set_target("blank");
$arHtml[] = new HelperRaw("</li>");
$arHtml[] = new HelperRaw("<li class=\"nav-item\">");
$arHtml["anchor_2"] = new HelperAnchor("Simple link");
$arHtml["anchor_2"]->add_class("nav-link");
$arHtml["anchor_2"]->set_href("#");
$arHtml[] = new HelperRaw("</li>");
$arHtml[] = new HelperRaw("</ul>");

foreach ($arHtml as $oHtml)
    $oHtml->show();
?>

HTML Result:

<ul class="nav nav-pills"><li class="nav-item"><a href="http://eduardoaf.com" target="_blank" class="nav-link active">Eduardoaf.com</a>
</li><li class="nav-item"><a href="#" class="nav-link">Simple link</a>
</li></ul>

Example 2


Live Html

Links in a form

Anchor 0 Anchor 1 Anchor 2

PHP Code:

<?php
use TheFramework\Helpers\HelperForm;
use TheFramework\Helpers\HelperP;

$oForm = new HelperForm();
$oForm->add_class("");
$oForm->add_style("border:1px dashed #4f9fcf;");
$oForm->add_style("padding:5px;");
$oForm->set_id("myForm");
$oForm->add_control(new HelperP("<b>Links in a form</b>"));
for($i=0; $i<3; $i++)
    $oForm->add_control(new HelperAnchor("Anchor $i","anchor_$i","#link"));

$oForm->show();
?>

HTML Result:

<form id="myForm" method="post" style="border:1px dashed #4f9fcf;;padding:5px;">
<p>
<b>Links in a form</b></p>
<a id="anchor_0" href="#link">Anchor 0</a>
<a id="anchor_1" href="#link">Anchor 1</a>
<a id="anchor_2" href="#link">Anchor 2</a>
</form>