This page is under construction!

OptimizedHtml PHPLibrary

Design for backend optimizedHTML PHPWine written in PHP (Hypertext Preprocessor)

About: Formerly known as PHPWine Vanilla flavour which end life beta version 1.4.0 was announce September 3, 2023 11PM PH. Officially released the PHPWine OptimizedHtml v1.3.0 which have a structured and methods, not just html but also fully optimized and organized inspired with the beauty of Laravel building app approach "similar" to MVC with three major class for more details will discuss with you soon! the Doctrines Class for templates, App Class for main application last but not the least is Components Classes.

When?: You can use PHPWine OptimizedHtml with any PHP Framework such Laravel, CodeIgniter, Symfony also compatible with any CMS such WordPress, Drupal etc... or even non-framework php web application.

Installation:

   
   /* required version *v1.4.0 */
   composer require phpwine/optimizedhtml v1.4.0
   
   
   /* Installing Doctrine local available soon! */
   composer require phpwine/doctrine v1.0
   
   
   /* Installing Doctrine local tailwindcss available soon! */
   composer require phpwine/doctrine-tailwindcss v1.0
   
   
   /* Installing Doctrine local bootstrapt available soon! */
   composer require phpwine/doctrine-boostrapt v1.0
   

Usage:


 /* Basic Usage */
  require dirname(__FILE__) . DIRECTORY_SEPARATOR .'/vendor/autoload.php';

  $tag = new PHPWineOptimizedHtml\OptimizedHtml;
    
  print $tag->wine(h1,'Hello World');

Congratulations you are now in PHPWine overview!

PHPWine Class Structure insights


  /* Structure Optimizing HTML */
  | - Doctrine 
    |- Class HomePageDoctrine { ... }
    | - App 
      |- Class HeaderApp { ... }
    | - Components 
      |- Class Branding { ... }
      |- Class MainMenu { ... }

Doctrine Class php file

Set your namespace and follow by Class keyword then you Doctrine class named

  
  /* Here is the example of Doctrine Class file .php */
  | - Doctrine
        
  namespace \YourLoader\folder;   

  Class HomePageDoctrine { 

   ...
 
  } 
  
  

Application Class php file


  /* Here is the example of App Class file .php */
  | - App (Main application)
          
  namespace \YourLoader\folder; 
      
  use \YourLoader\folder\HomePageDoctrine;
  
  Class HeaderApp Extends HomePageDoctrine  { 
  
    ...
   
  }

Component Brading Class php file


  /* Here is the example of Components Branding Class file .php */
  | - App (Main application)
          
  namespace \YourLoader\folder; 
      
  use \YourLoader\folder\HeaderApp;
  
  Class Branding Extends HeaderApp  { 
  
    ...
   
  }

Component MainMenu Class php file


  /* Here is the example of Components Main menu Class file .php */
  | - App (Main application)
          
  namespace \YourLoader\folder; 
      
  use \YourLoader\folder\HeaderApp;
  
  Class MainMenu Extends HeaderApp  { 
  
    ...
   
  }

Quick Start


 /* Quick Start file .php */
 | - Quick Start
Download for wine v1.3.2 to v1.3.4 higher

/* init doctrine class */
 < html lang="en">
 < body>
   ...
 < ?php 
 /**
 * --------------------------------------------------------------------------------------------
 * @class 
 * @hide_those
 * @source: project/Components\HomePageThose.php
 * -------------------------------------------------------------------------------------------- 
 * DT: 11.17.2023 **/ 
 $those_boxes = new \PHPWineShowcase\Components\HomePageThose;
 
  wine_doctrine_init(); ?>  
 < /body>
 < /html>  


 < ?php 
  
 /* Instead of using doctrine selecting 1 by 1 you can use those
 property and select the class and those */
 
  namespace PHPWineShowcase\Components;

  use \PHPWineOptimizedHtml\Doctrine\Doctrine;

  class HomePageThose {

  public function __construct()
  {

  // Hide in mobile
  $page_box =  new Doctrine([
   those => '.hide-m'  
  ]);  

  print $page_box->visible([
   'sm_mobile' => false 
  ])->screen([
   'sm_mobile' => 540 
  ])->layout();

  ... // add more 
  }
 } 
 
Structure
Doctrine
App
Components

PHPWine Methods

PHPWine OptimizedHtml has predefined methods, these methods are helpful for developer to minimize and lessen the workload, and it makes the structure simpler and effective.

wine function|method : Use to generate optimized html. - wine(); is primary init function in order to have optimized html it is also use in order to create a condition before using "please" reserve keyword, The "try" or "please" is more secured when you wrap them in wine before you use.

- Inside the wine(); you can also create a child using predefined array child and it's keyword "child" with this key you can create a descendant element like div or any within the providers property inside the wine class, more than that you can do custom HTML tag just using wine.

- In order to use a value, attr and magic hooks you have to call the wine function.

NOTE: Keep in mind : wine second parameter or content value is accept single single type of data! - wine(div,""); If you are working with array you always working with child array if you are working with string you must be stick on string type value. - wine(div,""); might accept different type of data however when you create child you must be stick on single type of data inside "please" or "try" it only rendered single type of data due to optimization, imagine you running holding cake or pizza?

Hooks: value(); attr(); magic(); are also method.

wine(); | Type: function|method

Defined: wine function or method is use to generate optimized html

 wine( 
   
  string $tag, 
  string|callable|array $content = [], 
  string|array $attr = [], 
  $enable_html = false 
  
 ); 
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @param string $tag : < require >
  - This is where you will assigned any html tag such as 'h1', 'div', 'p' etc.. 
  
  @param string|callable|array $content : < optional >
  - String : Any string value you want to display in a browser from a-Z and 0-inifinite 
             inlcuding special characters as long as in a form of string. 

  - Callable : It is in a form of string but actually name of your method or function 
               ex. "my_call_back". 

  - Array : It is predefined and reserved keyword "child key" it will able you to 
            create a child element html.

  @param string|array $attr :  < optional >
  - String: Directly use string to be your html attributes.

  - Array : Array approach to be your html attributes.

  @param $enable_html :  < optional >
   - Boolean : optional true or false default value is false.
   

wine with HTML tag < require >

/* wine with div tag HTML */
print wine('div');

wine with HTML Tag and value "String" < optional >

/* wine with div tag HTML value string  */
print wine('div','Hello World');

wine with HTML Tag and value "String call back" function < optional >

/* wine with div tag HTML value string call back */
print wine('div','my_call_back_function');

function my_call_back_function() {
   return "Hello World";
}

wine with HTML Tag and value "Array" child element < optional >

/* wine with div tag HTML value Array child element */
print wine('div',[
   child => [
     ['div', value =>['Hello World']]
   ]
]);

wine with HTML Tag and attribute String < optional >

/* wine with div tag HTML Attributes string */
print wine('div','Hello World','class="my-class" id="my_ids"'); /* make sure remove extrass spacing it reflect to html */

wine with HTML Tag and attribute Array < optional >

/* wine with div tag HTML Attributes array */
print wine('div','Hello World',[classes=>"one my-class" id=>"my_id"]); /*automatic removed extra spacing*/

wine enable html < optional >

/* wine with div tag HTML enable html optional */
print wine('div','Hello World',[classes=>"one my-class" id=>"my_id"], true ); /* default value is false*/

Wine Hooks

PHPWine has predefined Hooks, these hooks are helpful for developer to minimize and lessen the workload, and it makes the structure simpler and effective.

later function|hook : Use to return content for a call back function. - later(); is a string function that provide a callback for magic hook and "value" reserved keyword when you working with the child array there is a reserved keyword "value" and "attr" with these keys you can add attributes in your array custom html and write the "value" you can return a any form of string value to have a content that child array element or you can use the later() hook function to have a return call back that mostly do in procedural pages in you view php files. In addition later() hook is a optional function it doesnt matter if this exists unlike value hook is mandatory call back.

value method|hook : Use to return content for a call back function. - value(); is a string function that provide a callback for "value" reserved keyword when you working with the child array there is a reserved keyword "value" and "attr" with these keys you can add attributes in your array custom html and write the "value" you can return a any form of string value to have a content that child array element or you can use the value() hook function to have a return call back that mostly do in main app files, with that value function you can extract the content you want to return in your child array key html

magic method|hook : Use to filter the current content and replace. - magic(); is exactly the same as value(); aside to the time of execution however the return argument is the current value, The magic hook is use when you want to replace the current value of the html or the full app html, this magic hook method are mostly use in a session, for instance you have a different layout header when the user is login or active session else you have a default navigation once the user is logout. - you can also add magic if your client want to update the layout without touching the current structure so if ever there's a change of mind you don't need to do it over and over again and you can restore back the default immediately because you using magic hook for the temporary of time you are working with the new layout structure.

attr method|hook : Use to add or filter and replace the current attribute of your html. - attr(); is exactly the same as magic(); the same with the time of execution however the return argument is the current attribute, The attr hook is use when you want to replace the current attribute in the html, this attr() hook method are mostly use in a doctrine class php file, for instance you decided to develop or create a doctrine that exact match to your custom layout, with this hook you can use the doctrine as your parent template to have a reusable asset and replace the attributes according to your project next section layout.

later(); | Type: function|hook

Defined: later hook or function is use to create a content to the wine

 later( 
   
  string|callable $function_name = null,
  mixed ...$args 
   
 ); 
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @param string|callable| $function_back : < optional&nullable >
  - Callable : It is in a form of string but actually name of your method or function 
            ex. "my_call_back". 

  @param mixed ...$args :  < optional&nullable >
  - mixed: arguments data call back

later function/hook basic usage


   /* later function|hook */
   /* $this if you are within the class */ 
    print wine('div',[
     child => [
       [div, value=>[later('function_name', 1, 4, 3)]]
      ]
    ]);

   /* later stand for it doesnt matter if this function is exist or not, or might be later! */ 
   function function_name( $love, $sign, $wine ) {
     return "Hello World $love $sign $wine";
   }
   

value(); | Type: method|hook

Defined: value hook or method is use to create a reusable or single callable function

 value( 
   
  object $class = null,
  string|callable $call_back = null,
  mixed ...$args 
   
 ); 
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @param object $class  : < optional&nullable >
  - This object is the class of method you are working with the call-back

  @param string|callable| $call_back : < optional&nullable >
  - Callable : It is in a form of string but actually name of your method or function 
            ex. "my_call_back". 

  @param mixed ...$args :  < optional&nullable >
  - mixed: arguments data call back

value method/hook basic usage


  /* value function|method */
  /* $this if you are within the class */ 
  print value($this,'my_call_back', 'Developer');

   function my_call_back( $param ) {
     return "Hello World ".$param;
   }
  

value with in HTML


 /* value hook in HTML  */
  return wine('section', [

   child => [
     /* $this replace of object name you are working with your call back  */
     ['div', value=>[value((new Branding),'component_top_logo_header')]]
    ]
  ]);
 

magic(); | Type: method|hook

Defined: magic hook or method is use to filter and replace a current value with the callback

 magic( 
   
  object $class = null,
  string|callable $call_back = null,
  mixed ...$current_value /* first argument is a function */
   
 ); 
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @param object $class  : < optional&nullable >
  - This object is the class of method you are working with the call-back

  @param string|callable| $call_back : < optional&nullable >
  - Callable : It is in a form of string but actually name of your method or function 
            ex. "my_call_back". 

  @param mixed ...$current_value :  < optional&nullable >
  - mixed: arguments data call back

magic method/hook basic usage


 /* magic can wait until the exact Date and Time you wish to call or invoke it */
 /* $this if you are within the class */ 
  magic($this,'my_call_back', 'Developer');

  function my_call_back( $param ) {
    return "Hello World ".$param;
  }

  function Developer( $dev  ) {
  /* return  any... */
  }
  

magic with in HTML

/* working with magic method  */
 function current_value( $dev, $sign, $of, $love ) {
   /* Keep in mind first argument is name of function */
   return "I really fall with wine $sign $of $love";
 }
/* working with magic method  */
   
 /* using value in case of method in magic  */
 /* 
 $value = value($object, 'callable_method',$any);
 ['div', value=>[magic((new object),'method_filter',$value)]]
 */

 return wine('section', [

  child => [
  /* $this replace of object name you are working with your call back  */
    ['div', value=>[magic((new object),'method_filter','current_value', 1, 4, 3)]]
  ]
 ]);

attr(); | Type: method|hook

Defined: attr hook or method is use to add or filter and replace the current attribute of your html

 attr( 
   
  object $class = null,
  string|callable $call_back = null,
  mixed ...$args 
   
 ); 
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @param object $class  : < optional&nullable >
  - This object is the class of method you are working with the call-back

  @param string|callable| $call_back : < optional&nullable >
  - Callable : It is in a form of string but actually name of your method or function 
            ex. "my_call_back". 

  @param mixed ...$args :  < optional&nullable >
  - mixed: arguments data call back

attr method/hook basic usage


   /* attr hook|method */
   /* $this if you are within the class */ 
    public function doctrine_method_name($session) {

       return wine('section', [
        child => [
   
          ['div', attr=> [ attr((new object),'filter_attr',[ /* current attributes */ ]) ]],
        
        ]
       ]);
     }
  

Reserved Keywords

Defined: Reserved keyword is a type of constant that predefined in wine class those keys are uses in each significant purposes.
attr : attribute key uses to add attributes in your html inside in php file.
child : key uses to child element in your wine function in array approach in your html inside in php file.
value : key uses to add a content in any form of string inside this key.
__ : double underscore or known as magic entity key use to remove the parent when you don’t need it in your wine method mostly if you are working with please or “try” key
“please” or “try” Please and “try” layers : This is where you can able to add “try” or please keyword however as much as possible wrap the “try” or please keyword inside the wine(); with this approach you can easily trace you source code instead of putting please in a different layers.

  wine(__, [

   Child=> [
    /* goes here */
   ]
   
  ]);
    
  /* First Layer */
  wine('div', [ 
    child => [        
      please => function() { ... },
    ]
  ]);
  
  /* Second Layer */
  wine('div', [ 
    child => [ 
     ['try' => function() { ... } ],
    ]
  ]);
  
  /* Third layer */
  wine('div', [ 
    child => [ 
     [div, value => [ 'try' => function() { ... }] ],
    ]
  ]);
  
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

attr | Type: constant|ReservedKeyword

Defined: "attr" key use to add attribute in your html inside in php file


 attr => [ ] 
   
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @key constant attr   : < optional&require >
 

attr constant basic usage


  /* attr constant will only available inside the child key predefined array child element */ 
  print wine(div, [
   child => [
      [div, attr => [ classes=>"my-class" id=>"my_id"] ]
    ]
  ]);
  

child | Type: constant|ReservedKeyword

Defined: "child" key use to add array child element in your html inside in php file


 child => [ ] 
   
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @key constant child   : < optional&require >
 

child constant basic usage


  /* child key predefined array child element */ 
  print wine(div, [
   child => [
      [div, attr => [ classes=>"my-class" id=>"my_id"] ],
      [div, 
        attr => [ 
         classes=>"my-class" 
         id=>"my_id"
      ]]
    ]
  ]);
  

value | Type: constant|ReservedKeyword

Defined: "value" key use to add content to your array child element in your html inside in php file


 value => [ ] 
   
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @key constant child   : < optional&require >
 

child constant basic usage


  /* will accept any string value */ 
  print wine(div, [
   child => [
      [div, value => ["Hello World"]]
    ]
  ]);
  

__ | Type: constant|ReservedKeyword

Defined: "__" (double underscore) or known as magic entity key use to removed parent element in wine your html inside in php file


 wine(__,); 
   
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @key constant child   : < optional&require >
 

magic entity constant basic usage

 
  /* will only return child div with content "Hello World" */ 
  print wine(__, [
   child => [
      [div, value => ["Hello World"]]
    ]
  ]);
  

please | Type: constant|ReservedKeyword

Defined: "please" key use to add conidition or statement in your element in wine your html inside in php file


 please => function() { ... } 
   
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @key constant please   : < optional&require >
 

please constant basic usage


  /* wine() and array child cannot work togther inside the please keyword! */ 
  /* create condition before each child array */ 
  print wine(__, [ 
        
    child => [ 
    
    ['div', value => [ please => function() {

      $dd   = [];
      $dd[] = wine('h1', 'Hello!' );  /* only wine or child array element works */ 
       /* $dd[] = ['h1',  value => ['Hello World'] ];  if you use array child remove wine(); */ 
       foreach([1,2,3] as $data ) {

       $dd[] = wine('div', $data);
       /* $dd[] =  ['div',value => [$data] ,attr => [ classes => 'w-full'] ]; */
        
       } /* end of statement or condition */ 
      return $dd;
     }  /* end of please */ 
   ]]
   
 ]]);
  

"try" | Type: string|ReservedKeyword

Defined: "try" key use to add conidition or statement in your element in wine your html inside in php file


 "try" => function() { ... } 
   
Source: https://github.com/PHPWine/PHPWine/blob/main/src/OptimizedHtml.php

  @key string "try"   : < optional&require >
 

"try" string basic usage


  /* wine() and array child cannot work togther inside the please keyword! */ 
  /* create condition before each child array */ 
  print wine(__, [ 
        
  child => [ 
  
  ['div', value => [ "try" => function() {

    $new = new class () extends \AppNameSpace\ClassName {

      public function my_value_in_array() {
        return "Coffee";
      }

      public function my_filter() {
        return "No sugar!";
      }

    };

    return [
      
      ['div', value => [value($new,'my_value_in_array')]],
      ['div', value => [magic($new,'my_filter',value($new,'my_value_in_array'))]]
  
    ];

  }]]
 
]]);
  

Entity Attribute

Defined: Entity attribute keyword is a predefined constant that only available inside the wine class, these also available in your php file once you initialized the OptimizedHtml PHPWine library.

This is merging the layout like feel in literal HTML, in php file you are not able to add entity attribute just the same as html, because it’s rendered you need to put these inside array then print as string in html, like ex.[ “key” => “val”]; but with these entity constant you can now feel the super natural approach adding entity attributes with these registered constant lists it help to developer to make the wine more effective.

Alt Type: Constant|ReservedKeyword

Defined: Alt Attribute

alt: Key is mostly use in image HTML it is alternative use once the image cannot load to the browser so the client will be able to determined which image are they see through the alt name, imagine you have a product that have link using images? And your server getting issue then the images cannot load? This “alt” key may help your visitor to figure out which button are they should to click, in addition this alt key are being use in SEO for search engine optimization in all types of browser.


                        print wine(img,null,[alt=>"name-any"]);
                        

classses Type: Constant|ReservedKeyword

Defined: class Attribute

class is mostly use to add a layout through css you can have multiple classes at the time.


                        print wine(div,"Hello World",[classes=>"name-any"]);
                        

controls Type: Constant|ReservedKeyword

Defined: class Attribute

If this attribute is present, the browser will offer controls to allow the user to control video playback, including volume, seeking, and pause/resume playback.

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
dir deprecated @since htmlv4

for Type: Constant|ReservedKeyword

Defined: for Attribute

the for attribute has a value which is the id of the form element it relates to.

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/for

href Type: Constant|ReservedKeyword

Defined: href Attribute

The href property of the Location interface is a stringifier that returns a string containing the whole URL, and allows the href to be updated.

Source: https://developer.mozilla.org/en-US/docs/Web/API/Location/href

height Type: Constant|ReservedKeyword

Defined: height Attribute

The height CSS property specifies the height of an element.

Source: https://developer.mozilla.org/en-US/docs/Web/CSS/height

id Type: Constant|ReservedKeyword

Defined: id Attribute

The id property of the Element interface represents the element's identifier, reflecting the id global attribute.

Source: https://developer.mozilla.org/en-US/docs/Web/API/Element/id

lists Type: Constant|ReservedKeyword

Defined: lists Attribute

Lists behave like any other text for the most part, but there are some CSS properties specific to lists that you need to know about, as well as some best practices to consider. This article explains all.

Source: https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_text/Styling_lists

max Type: Constant|ReservedKeyword

Defined: max Attribute

The max attribute defines the maximum value that is acceptable and valid for the input containing the attribute.

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max

min Type: Constant|ReservedKeyword

Defined: min Attribute

The min() CSS function lets you set the smallest (most negative) value from a list of comma-separated expressions as the value of a CSS property value.

Source: https://developer.mozilla.org/en-US/docs/Web/CSS/min

name Type: Constant|ReservedKeyword

Defined: name Attribute

Source: https://developer.mozilla.org/en-US/docs/Web/API/File/name

style Type: Constant|ReservedKeyword

Defined: style Attribute

The read-only style property of the HTMLElement returns the inline style of an element in the form of a live CSSStyleDeclaration object that contains a list of all styles properties for that element with values assigned only for the attributes that are defined in the element's inline style attribute.

Source: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style

script Type: Constant|ReservedKeyword

Defined: script Attribute

Source: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/script

src Type: Constant|ReservedKeyword

Defined: src Attribute

Source: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src Source:https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/src

type Type: Constant|ReservedKeyword

Defined: type Attribute

Source: https://developer.mozilla.org/en-US/docs/Web/API/Event/type

target Type: Constant|ReservedKeyword

Defined: target Attribute

Source: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/target

val Type: Constant|ReservedKeyword

Defined: val Attribute

Source: https://api.jquery.com/val/#val

with Type: Constant|ReservedKeyword

Defined: with Attribute

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
Entity HTML5
a (anchor tag)
action
area
abbr
address
article
aside
audio
base
b
bdi
bdo
blockquote
br
button
body
coords
content
cite
canvas
caption
code
col
cols
colgroup
circle
cx
cy
del
div
dfn
dialog
details
data
datalist
dl
dt
datetime
em
embed
fill
fieldset
figure
figcaption
footer
form
hr
h1
h2
h3
h4
h5
h6
head
html
img
input
i
iframe
ins
kbd
legend
label
link
lang
li
media
meter
mark
meta
main
method
map
nav
noscript
oninput
optgroup
option
output
object
ol
open
p
param
picture
pre
progress
q
r
ruby
rp
rt
rows
samp
small
span
strong
sub
summary
sup
svg
s
select
shape
summary
src
source
stroke
stroke-width
tfoot
th
thead
tr
track
tt
title
table
tbody
td
template
textarea
ul
usemap
u
var
video
wbr