Skip to content

Phalcon html

NOTE

All classes are prefixed with Phalcon

Html\Attributes

Source on GitHub

  • Namespace

    • Phalcon\Html
  • Uses

    • Phalcon\Html\Attributes\RenderInterface
    • Phalcon\Collection
  • Extends

    Collection

  • Implements

    • RenderInterface

This class helps to work with HTML Attributes

Methods

public function __toString(): string;
Alias of the render method

public function render(): string;
Render attributes as HTML attributes

Html\Attributes\AttributesInterface Interface

Source on GitHub

  • Namespace

    • Phalcon\Html\Attributes
  • Uses

    • Phalcon\Html\Attributes
  • Extends

  • Implements

  • Phalcon\Html\Attributes\AttributesInterface *

  • Interface Phalcon\Html\Attributes\AttributesInterface */

Methods

public function getAttributes(): Attributes;
Get Attributes

public function setAttributes( Attributes $attributes ): AttributesInterface;
Set Attributes

Html\Attributes\RenderInterface Interface

Source on GitHub

  • Namespace

    • Phalcon\Html\Attributes
  • Uses

  • Extends

  • Implements

Methods

public function render(): string;
Generate a string represetation

Html\Breadcrumbs

Source on GitHub

  • Namespace

    • Phalcon\Html
  • Uses

    • Phalcon\Di\DiInterface
  • Extends

  • Implements

Phalcon\Html\Breadcrumbs

This component offers an easy way to create breadcrumbs for your application. The resulting HTML when calling render() will have each breadcrumb enclosed in <dt> tags, while the whole string is enclosed in <dl> tags.

Properties

/**
 * Keeps all the breadcrumbs
 *
 * @var array
 */
private $elements;

/**
 * Crumb separator
 *
 * @var string
 */
private $separator =  '/' ;

/**
 * The HTML template to use to render the breadcrumbs.
 *
 * @var string
 */
private $template = "<dt><a href=\"%link%\">%label%</a></dt>";

Methods

public function add( string $label, string $link = string ): Breadcrumbs;
Adds a new crumb.

// Adding a crumb with a link
$breadcrumbs->add("Home", "/");

// Adding a crumb without a link (normally the last one)
$breadcrumbs->add("Users");

public function clear(): void;
Clears the crumbs

$breadcrumbs->clear()

public function getSeparator(): string;
Crumb separator

public function remove( string $link ): void;
Removes crumb by url.

$breadcrumbs->remove("/admin/user/create");

// remove a crumb without an url (last link)
$breadcrumbs->remove();

public function render(): string;
Renders and outputs breadcrumbs based on previously set template.

echo $breadcrumbs->render();
public function setSeparator( string $separator )

public function toArray(): array;
Returns the internal breadcrumbs array

Html\Escaper\Exception

Source on GitHub

  • Namespace

    • Phalcon\Html\Escaper
  • Uses

  • Extends

    \Exception

  • Implements

Exceptions thrown in Phalcon\Html\Escaper will use this class

Html\Helper\AbstractHelper Abstract

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Escaper\EscaperInterface
    • Phalcon\Html\Exception
  • Extends

  • Implements

Properties

/**
 * @var string
 */
protected $delimiter = '';

/**
 * @var EscaperInterface
 */
protected $escaper;

/**
 * @var string
 */
protected $indent = '    ';

/**
 * @var int
 */
protected $indentLevel = 1;

Methods

public function __construct( EscaperInterface $escaper );
AbstractHelper constructor.

protected function close( string $tag, bool $raw = bool ): string;
Produces a closing tag

protected function indent(): string;
Replicates the indent x times as per indentLevel

protected function orderAttributes( array $overrides, array $attributes ): array;
Keeps all the attributes sorted - same order all the tome

protected function renderArrayElements( array $elements, string $delimiter ): string;
Traverses an array and calls the method defined in the first element with attributes as the second, returning the resulting string

protected function renderAttributes( array $attributes ): string;
Renders all the attributes

protected function renderElement( string $tag, array $attributes = [] ): string;
Renders an element

protected function renderFullElement( string $tag, string $text, array $attributes = [], bool $raw = bool ): string;
Renders an element

protected function renderTag( string $tag, array $attributes = [], string $close = string ): string;
Renders a tag

protected function selfClose( string $tag, array $attributes = [] ): string;
Produces a self close tag i.e.

Html\Helper\AbstractList Abstract

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class AbstractList

Properties

/**
 * @var array
 */
protected $attributes;

/**
 * @var string
 */
protected $elementTag = "li";

/**
 * @var array
 */
protected $store;

Methods

public function __invoke( string $indent = null, string $delimiter = null, array $attributes = [] ): AbstractList;

public function __toString();
Generates and returns the HTML for the list.

abstract protected function getTag(): string;
Returns the tag name.

Html\Helper\AbstractSeries Abstract

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

  • Extends

    AbstractHelper

  • Implements

Properties

/**
 * @var array
 */
protected $attributes;

/**
 * @var array
 */
protected $store;

Methods

public function __invoke( string $indent = null, string $delimiter = null ): AbstractSeries;

public function __toString();
Generates and returns the HTML for the list.

abstract protected function getTag(): string;
Returns the tag name.

Html\Helper\Anchor

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Anchor

Methods

public function __invoke( string $href, string $text, array $attributes = [], bool $raw = bool ): string;
Produce a tag

protected function processAttributes( string $href, array $attributes ): array;

Html\Helper\Base

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Base

Methods

public function __invoke( string $href = null, array $attributes = [] ): string;
Produce a <base/> tag.

Html\Helper\Body

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Body

Methods

public function __invoke( array $attributes = [] ): string;
Produce a <body> tag.

Html\Helper\Button

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Button

Methods

public function __invoke( string $text, array $attributes = [], bool $raw = bool ): string;
Produce a <button> tag.

Html\Helper\Close

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

  • Extends

    AbstractHelper

  • Implements

Class Close

Methods

public function __invoke( string $tag, bool $raw = bool ): string;
Produce a </...> tag.

Html\Helper\Element

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Element

Methods

public function __invoke( string $tag, string $text, array $attributes = [], bool $raw = bool ): string;
Produce a tag.

Html\Helper\Form

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Form

Methods

public function __invoke( array $attributes = [] ): string;
Produce a <form> tag.

Html\Helper\Img

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Img

Methods

public function __invoke( string $src, array $attributes = [] ): string;
Produce a tag.

Html\Helper\Input\AbstractInput Abstract

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

    • Phalcon\Html\Helper\AbstractHelper
  • Extends

    AbstractHelper

  • Implements

Class AbstractInput

Properties

/**
 * @var string
 */
protected $type = 'text';

/**
 * @var array
 */
protected $attributes;

Methods

public function __invoke( string $name, string $value = null, array $attributes = [] ): AbstractInput;

public function __toString();
Returns the HTML for the input.

public function setValue( string $value = null ): AbstractInput;
Sets the value of the element

Html\Helper\Input\Checkbox

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

    • Phalcon\Html\Escaper\EscaperInterface
  • Extends

    AbstractInput

  • Implements

Class Checkbox

Properties

/**
 * @var array
 */
protected $label;

/**
 * @var string
 */
protected $type = 'checkbox';

Methods

public function __construct( EscaperInterface $escaper );
AbstractHelper constructor.

public function __toString();
Returns the HTML for the input.

public function label( array $attributes = [] ): Checkbox;
Attaches a label to the element

Html\Helper\Input\Color

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Color

Properties

//
protected $type = 'color';

Html\Helper\Input\Date

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Date

Properties

//
protected $type = 'date';

Html\Helper\Input\DateTime

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class DateTime

Properties

//
protected $type = 'datetime';

Html\Helper\Input\DateTimeLocal

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class DateTimeLocal

Properties

//
protected $type = 'datetime-local';

Html\Helper\Input\Email

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Email

Properties

//
protected $type = 'email';

Html\Helper\Input\File

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class File

Properties

//
protected $type = 'file';

Html\Helper\Input\Hidden

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Hidden

Properties

//
protected $type = 'hidden';

Html\Helper\Input\Image

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Image

Properties

//
protected $type = 'image';

Html\Helper\Input\Input

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Input

Methods

public function setType( string $type ): AbstractInput;
Sets the type of the input

Html\Helper\Input\Month

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Month

Properties

//
protected $type = 'month';

Html\Helper\Input\Numeric

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Numeric

Properties

//
protected $type = 'numeric';

Html\Helper\Input\Password

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Password

Properties

//
protected $type = 'password';

Html\Helper\Input\Radio

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    Checkbox

  • Implements

Class Radio

Properties

/**
 * @var string
 */
protected $type = 'radio';

Html\Helper\Input\Range

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Range

Properties

//
protected $type = 'range';

Html\Helper\Input\Search

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Search

Properties

//
protected $type = 'search';

Html\Helper\Input\Select

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

    • Phalcon\Html\Helper\AbstractList
  • Extends

    AbstractList

  • Implements

Class Select

Properties

/**
 * @var string
 */
protected $elementTag = 'option';

/**
 * @var bool
 */
protected $inOptGroup = false;

/**
 * @var string
 */
protected $selected = ;

Methods

public function add( string $text, string $value = null, array $attributes = [], bool $raw = bool ): Select;
Add an element to the list

public function addPlaceholder( string $text, mixed $value = null, array $attributes = [], bool $raw = bool ): Select;
Add a placeholder to the element

public function optGroup( string $label = null, array $attributes = [] ): Select;
Creates an option group

public function selected( string $selected ): Select;
protected function getTag(): string;
protected function optGroupEnd(): string;
protected function optGroupStart( string $label, array $attributes ): string;

Html\Helper\Input\Submit

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Submit

Properties

//
protected $type = 'submit';

Html\Helper\Input\Tel

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Tel

Properties

//
protected $type = 'tel';

Html\Helper\Input\Text

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Text

Html\Helper\Input\Textarea

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractInput

  • Implements

Class Textarea

Properties

/**
 * @var string
 */
protected $type = 'textarea';

Methods

public function __toString();
Returns the HTML for the input.

Html\Helper\Input\Time

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Time

Properties

//
protected $type = 'time';

Html\Helper\Input\Url

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Url

Properties

//
protected $type = 'url';

Html\Helper\Input\Week

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper\Input
  • Uses

  • Extends

    AbstractInput

  • Implements

Class Week

Properties

//
protected $type = 'week';

Html\Helper\Label

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Label

Methods

public function __invoke( string $label, array $attributes = [], bool $raw = bool ): string;
Produce a <label> tag.

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

  • Extends

    Style

  • Implements

Creates tags

Methods

public function add( string $url, array $attributes = [] );
Add an element to the list

protected function getAttributes( string $url, array $attributes ): array;
Returns the necessary attributes

protected function getTag(): string;

Html\Helper\Meta

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractSeries

  • Implements

Class Meta

Methods

public function add( array $attributes = [] ): Meta;
Add an element to the list

public function addHttp( string $httpEquiv, string $content ): Meta;
public function addName( string $name, string $content ): Meta;
public function addProperty( string $name, string $content ): Meta;
protected function getTag(): string;

Html\Helper\Ol

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

  • Extends

    AbstractList

  • Implements

Class Ol

Methods

public function add( string $text, array $attributes = [], bool $raw = bool ): AbstractList;
Add an element to the list

protected function getTag(): string;

Html\Helper\Script

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractSeries

  • Implements

Class Script

Methods

protected function getAttributes( string $src, array $attributes ): array;
Returns the necessary attributes

protected function getTag(): string;

Html\Helper\Style

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractSeries

Class Style

Methods

public function add( string $href, array $attributes = [] );
Add an element to the list

protected function getAttributes( string $href, array $attributes ): array;
Returns the necessary attributes

protected function getTag(): string;

Html\Helper\Title

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

    • Phalcon\Html\Exception
  • Extends

    AbstractHelper

  • Implements

Class Title

Properties

/**
 * @var array
 */
protected $append;

/**
 * @var array
 */
protected $prepend;

/**
 * @var string
 */
protected $title = ;

/**
 * @var string
 */
protected $separator = ;

Methods

public function __invoke( string $separator = string, string $indent = null, string $delimiter = null ): Title;
Sets the separator and returns the object back

public function __toString();
Returns the title tags

public function append( string $text, bool $raw = bool ): Title;
Appends text to current document title

public function get(): string;
Returns the title

public function prepend( string $text, bool $raw = bool ): Title;
Prepends text to current document title

public function set( string $text, bool $raw = bool ): Title;
Sets the title

Html\Helper\Ul

Source on GitHub

  • Namespace

    • Phalcon\Html\Helper
  • Uses

  • Extends

    Ol

  • Implements

Class Ul

Methods

protected function getTag(): string;

Source on GitHub

  • Namespace

    • Phalcon\Html\Link
  • Uses

    • Psr\Link\EvolvableLinkInterface
  • Extends

    • Link
  • Implements

    • EvolvableLinkInterface

Class Phalcon\Http\Link\EvolvableLink

Methods

public function withAttribute( mixed $attribute, mixed $value );
Returns an instance with the specified attribute added.

If the specified attribute is already present, it will be overwritten with the new value.

public function withHref( mixed $href );
Returns an instance with the specified href.

public function withRel( mixed $rel );
Returns an instance with the specified relationship included.

If the specified rel is already present, this method MUST return normally without errors, but without adding the rel a second time.

public function withoutAttribute( mixed $attribute );
Returns an instance with the specified attribute excluded.

If the specified attribute is not present, this method MUST return normally without errors.

public function withoutRel( mixed $rel );
Returns an instance with the specified relationship excluded.

If the specified rel is not present, this method MUST return normally without errors.

Html\Link\EvolvableLinkProvider

Source on GitHub

  • Namespace

    • Phalcon\Html\Link
  • Uses

    • Psr\Link\EvolvableLinkProviderInterface
    • Psr\Link\LinkInterface
  • Extends

    LinkProvider

  • Implements

    • EvolvableLinkProviderInterface

Class Phalcon\Http\Link\LinkProvider

Methods

public function withLink( LinkInterface $link );
Returns an instance with the specified link included.

If the specified link is already present, this method MUST return normally without errors. The link is present if link is === identical to a link object already in the collection.

public function withoutLink( LinkInterface $link );
Returns an instance with the specified link removed.

If the specified link is not present, this method MUST return normally without errors. The link is present if link is === identical to a link object already in the collection.

Source on GitHub

  • Namespace

    • Phalcon\Html\Link
  • Uses

    • Psr\Link\LinkInterface
    • Phalcon\Collection
    • Phalcon\Collection\CollectionInterface
  • Extends

  • Implements

    • LinkInterface

Class Phalcon\Http\Link\Link

Properties

/**
 * @var Collection|CollectionInterface
 */
protected $attributes;

/**
 * @var string
 */
protected $href = '';

/**
 * @var Collection|CollectionInterface
 */
protected $rels;

/**
 * @var bool
 */
protected $templated = false;

Methods

public function __construct( string $rel = string, string $href = string, array $attributes = [] );
Link constructor.

public function getAttributes();
Returns a list of attributes that describe the target URI.

public function getHref();
Returns the target of the link.

The target link must be one of: - An absolute URI, as defined by RFC 5988. - A relative URI, as defined by RFC 5988. The base of the relative link is assumed to be known based on context by the client. - A URI template as defined by RFC 6570.

If a URI template is returned, isTemplated() MUST return True.

public function getRels();
Returns the relationship type(s) of the link.

This method returns 0 or more relationship types for a link, expressed as an array of strings.

public function isTemplated();
Returns whether or not this is a templated link.

protected function hrefIsTemplated( string $href ): bool;
Determines if a href is a templated link or not.

@see https://tools.ietf.org/html/rfc6570

Html\Link\LinkProvider

Source on GitHub

  • Namespace

    • Phalcon\Html\Link
  • Uses

    • Psr\Link\Interfaces\LinkInterface
    • Psr\Link\Interfaces\LinkProviderInterface
  • Extends

  • Implements

    • LinkProviderInterface

Properties

/**
 * @var LinkInterface[]
 */
protected $links;

Methods

public function __construct( array $links = [] );
LinkProvider constructor.

public function getLinks();
Returns an iterable of LinkInterface objects.

The iterable may be an array or any PHP \Traversable object. If no links are available, an empty array or \Traversable MUST be returned.

public function getLinksByRel( mixed $rel );
Returns an iterable of LinkInterface objects that have a specific relationship.

The iterable may be an array or any PHP \Traversable object. If no links with that relationship are available, an empty array or \Traversable MUST be returned.

protected function getKey( LinkInterface $link ): string;
Returns the object hash key

Html\Link\Serializer\Header

Source on GitHub

  • Namespace

    • Phalcon\Html\Link\Serializer
  • Uses

    • Psr\Link\EvolvableLinkInterface
  • Extends

  • Implements

    • SerializerInterface

Class Phalcon\Http\Link\Serializer\Header

Methods

public function serialize( array $links ): string | null;
Serializes all the passed links to a HTTP link header

Html\Link\Serializer\SerializerInterface Interface

Source on GitHub

  • Namespace

    • Phalcon\Html\Link\Serializer
  • Uses

  • Extends

  • Implements

Class Phalcon\Http\Link\Serializer\SerializerInterface

Methods

public function serialize( array $links ): string | null;
Serializer method

Html\TagFactory

Source on GitHub

  • Namespace

    • Phalcon\Html
  • Uses

    • Phalcon\Escaper
    • Phalcon\Escaper\EscaperInterface
    • Phalcon\Factory\AbstractFactory
  • Extends

    AbstractFactory

  • Implements

ServiceLocator implementation for Tag helpers.

Properties

/**
 * @var EscaperInterface
 */
private $escaper;

Methods

public function __construct( EscaperInterface $escaper, array $services = [] );
TagFactory constructor.

public function newInstance( string $name ): mixed;
protected function getAdapters(): array;