The Framework PHP Helpers



Examples of PHP Helper class: "HelperImage"

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 "img":
<img src="..." class="img-fluid" alt="Responsive image">

Examples:


Example 1


Live Html

Responsive image

PHP Code:

<?php
use TheFramework\Helpers\HelperImage;
$oImage = new HelperImage();
$oImage->set_src("http://images.locanto.net/2105338549/Best-CDN-Providers-CDN-Solution-Provider_2.png");
$oImage->set_alt("Responsive image");
$oImage->set_class("img-fluid");
$oImage->show();
?>

HTML Result:

<img src="http://images.locanto.net/2105338549/Best-CDN-Providers-CDN-Solution-Provider_2.png" alt="Responsive image" class="img-fluid">

Example 2


Live Html

Facebook alt proptwitter alt prop


PHP Code:

<?php
use TheFramework\Helpers\HelperImage;
use TheFramework\Helpers\HelperDiv;

$oDiv = new HelperDiv();
$oDiv->add_extras("id","divContainer");

$arImage["facebook"] = new HelperImage();
$arImage["facebook"]->set_alt("Facebook alt prop");
$arImage["facebook"]->set_src("https://cdn4.iconfinder.com/data/icons/miu-gloss-social/60/facebook-512.png");
$arImage["facebook"]->add_class("rounded");
$arImage["facebook"]->add_class("float-left");
$arImage["facebook"]->add_extras("height","50");

$arImage["twitter"] = new HelperImage();
$arImage["twitter"]->add_extras("someattr","some value for attr");
$arImage["twitter"]->set_alt("twitter alt prop");
$arImage["twitter"]->set_src("https://cdn4.iconfinder.com/data/icons/miu-gloss-social/60/twitter-512.png");
$arImage["twitter"]->add_class("rounded");
$arImage["twitter"]->add_class("float-right");
$arImage["twitter"]->add_extras("height","50");

$oDiv->add_inner_object($arImage["facebook"]);
$oDiv->add_inner_object($arImage["twitter"]);

$oDiv->show();
?>

HTML Result:

<div id="divContainer">
<img src="https://cdn4.iconfinder.com/data/icons/miu-gloss-social/60/facebook-512.png" alt="Facebook alt prop" class="rounded float-left" height="50"><img src="https://cdn4.iconfinder.com/data/icons/miu-gloss-social/60/twitter-512.png" alt="twitter alt prop" class="rounded float-right" someattr="some value for attr" height="50"></div>