phacil/html

Phacil PHP Framework HTML Classes

1.1.2 2019-07-18 19:45 UTC

This package is auto-updated.

Last update: 2024-04-19 06:10:04 UTC


README

HTML class is a component of Phacil PHP Framework

Instalation

Download zip from https://github.com/phacil/html, unzip file and use composer update inside folder

Now you can use the static methods to write HTML tags and its attributes in chain mode.

Loading HTML Class

<?php
include 'vendor/autoload.php';
use Phacil\Component\HTML\HTML;

Writing Elements

/* You can echo this code */
echo HTML::h1('This is a title');
/* or call output() function */
HTML::h2('This is a second title')->output();
/* and use chain mode to set attributes */
echo HTML::a('A link to google.com')->href('http:://google.com.br')->class('link');

Start a block

echo HTML::begin('div')->class('block')->id('content');
echo HTML::p(There is some content);
echo HTML::end('div');
/* or */
echo HTML::div(function(){
	echo HTML::p(There is some content);
})->class('block')->id('content');
/* or */	
echo HTML::div([
 	HTML::p(There is some content),
HTML::p(Another content)
]);

Especial Tags Function

You can write any tag with same structure shown above, except these guys:

/* Let's use this list */
$list = ["1"=>"First","Second","Third"];

Select

echo HTML::select($list, "2", $empty="Position")->id("select")->name("select");

Radio

echo HTML::radio($list, "2")->id("radios")->name("radios")->class("hotizontal");

Checkbox

echo HTML::checkbox($list, ["1" , "2"])->id("checkbox")->name("checkbox")->class("hotizontal");

Style

Now, we gonna write some CSS. This code:

$style = ['.btn-group' => [
               ' .btn'=> [                    
                        'color'=>'#ccc',
                        'padding'=>'0',
                        '.primary'=>[
                                    'color'=>'#08c',
                                    '.active'=>['color'=>'#08c'],
                        ],
                        '.danger'=>['color'=>'#F66']
                ],
            ],
        ];
echo HTML::style($style)

Out this:

<style>
     .btn-group{
      }
     .btn-group .btn{
          color:#ccc;
          padding:0;
      }
     .btn-group .btn.primary{
          color:#08c;
      }
     .btn-group .btn.primary.active{
          color:#081;
      }
     .btn-group .btn.danger{
          color:#08c;
      }
</style>