Download the PHP package panda/html without Composer
On this page you can find all versions of the php package panda/html. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package html
Short Description The Panda Html Package.
License MIT
Homepage http://pandaphp.org
Informations about the package html
Html Package
Note: [READ-ONLY] Subtree split of the Panda Ui Package
The Html Package allows you to create and manipulate Html Controls and other Html specific tools.
- Introduction
- Installation
- Through the composer
- HTML
- HTML Handlers
- HTML Factories
- HTML Basics
- HTML Forms
Introduction
Panda Ui Html component is a backend ui handler/renderer engine that enables generating html content in a more structured way.
This is the main reason why this component is so powerful, providing extra, faster and more clever functionality using existing components.
This package is able to create html pages using the DOM structure fast and easy. Some of the features include:
- Html specific controls and manipulation
- Html controls ready to be used
- Backend Html parsing and selecting using css selectors
- Form factories and builders
- Generic components
Installation
Through the composer
Add the following line to your composer.json
file:
HTML
HTML Handlers
HTMLHandler extends DOMHandler functionality with HTML specific functions. It provides easy-to-use one-line functions for handling HTML specific attributes so that we can make HTML rendering and manipulation easier. Examples:
One of the most important functionalities (and useful) is select(). This function acts like a jQuery selector function, where we can provide a css selector and return the matched items. This function returns a DOMNodeList object and those objects can be manipulated using the handler itself:
HTMLHandler provides a list of HTML-specific functionalities:
addClass(DOMElement &$element, $class)
removeClass(DOMElement &$element, $class)
hasClass(DOMElement $element, $class)
style(DOMElement &$element, $name, $val = '')
innerHTML(DOMElement &$element, $value = null, $faultTolerant = true, $convertEncoding = true)
outerHTML(DOMElement $element)
select(DOMDocument $document, $selector, $context = null)
HTML Factories
Extending DOM Factory, we have created HTML Factory for HTML-specific functionality and building. The HTML Factory provides an interface for building html elements which would need more than 2 or 3 lines to be built. This factory is being used the same way as the previous factory, in HTMLDocument object. Supported functionality:
buildHtmlElement($name = '', $value = '', $id = '', $class = '');
buildWebLink($href = '', $target = '_self', $content = '', $id = '', $class = '');
buildMeta($name = '', $content = '', $httpEquiv = '', $charset = '');
buildLink($rel, $href);
buildScript($src, $async = false);
DOMDocument and HTMLDocument both accept a DOMFactory and an HTMLFactory accordingly so that they can build their elements. The factories are being injected in the constructor, which means that they can be replaced by any DOMFactoryInterface or HTMLFactoryInterface.
HTML Basics
HTMLDocument
Extending basic DOMPrototype, we have created the HTMLDocument object that can be used specifically for HTML pages. It's a base class for easily creating HTML pages, also having access to the HTMLFactory class which provides a lot of functions for creating different html elements.
HTMLElement
Now that we have seen the DOMItem and the basic DOM functionality, which extends the native DOMElement functionality, we are introducing the HTMLElement. HTMLElements extend the base DOMItem and offer a new HTML-specific functionality to allow us to create HTML pages, elements and snippets.
The HTML element provides the following functionality as extra and HTML-specific:
data($name, $value = []);
addClass($class);
removeClass($class);
hasClass($class);
style($name, $val = '');
innerHTML($value = null, $faultTolerant = true, $convertEncoding = true);
outerHTML();
select($selector, $context = null);
All the previous functions are using the HTMLHandler that is given in the HTMLDocument that the HTMLElement accepts at the constructor.
HTML Forms
Platform Generic Form Element
Form builder/factory allows the creation of items with all the appropriate attributes in single-line calls. formItem is an internal object that is being used by the form builder in order to have less, more flexible and smarter code.
PHP Examples
Platform Generic Form Input
Form builder/factory allows the creation of inputs with all the appropriate attributes in single-line calls. FormInput is an internal object that is being used by the form builder in order to have less, more flexible and smarter code.
The FormInput extends the FormElement which minimizes the code even more, allowing the platform to be faster and more efficient. Example:
As seen above, we can create input items given the type and the name. Of course, in a form we can use more than inputs (select, textarea etc.) and this is why there is the FormElement object.