Download the PHP package artyuum/html-element without Composer

On this page you can find all versions of the php package artyuum/html-element. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package html-element

HtmlElement

A PHP library giving you the ability to generate HTML elements in an object oriented way.

Why did I create this ?

I used to work on a non-MVC PHP project and sometimes I needed to output few lines of HTML directly from the functions. Having to mix HTML code in PHP code was inconsistent to me and it was hard to keep the code easily readable and easy to maintain in the longterm because of the crazy and ugly concatenations. That's why I came up with the idea of generating HTML elements directly in PHP. (of course if you need to create many HTML elements, you should consider using a templating engine instead)
There are few existing libraries on Packagist that have the same purpose but I wasn't really satisfied and I also wanted to create my own library for fun & learning purpose.

Features

Requirements

Installation

Examples

Simple

A simple DIV element with some attributes & a content.

Output

Advanced

An example of a login form that contains children.

Output

API

Artyum\HtmlElement\Element

When instantiating the Element class, you can optionally provide the name of the element as first argument, and an array of options as second argument.


Gets the HTML code of the element.

If you call this method without setting the name property first, a LogicException will be thrown.

Note that you can also simply echo the instance and it will internally call the toHtml() method. This is possible thanks to the __toString() magic method.

Example


Gets the name of the element.


Sets the name of the element.


Gets the options of the element.


Sets the options of the element.

Available options :

Name Type Description
autoclose boolean Whether the element should have closing tag or not.

Gets the attributes assigned to the element.


Adds one or multiple attributes to the element.

Thanks to the splat operator (...), you can pass as much argument as you want. You can also call this method multiple times to add additional attributes.


Returns the content of the element.


Adds one or multiple contents to the element. You can pass a string, an integer, a float or an instance of the Element class.

Artyum\HtmlElement\Attribute

When instantiating the Attribute class, you must provide the name of the attribute and its value. You can optinally pass the separator that will be used to separate the values if you pass an array of values.


Gets the name.


Sets the name.


Gets the value.


Sets the value.


Gets the separator.


Sets the attribute values separator.


Builds & returns the HTML representation of the attribute.

If you call this method without setting the name or the value property first, a LogicException will be thrown.

You can also echo the instance and it will internally call the build() method.

Changelog

This library follows semantic versioning.

Contributing

If you'd like to contribute, please fork the repository and make changes as you'd like. Be sure to follow the same coding style & naming used in this library to produce a consistent code.


All versions of html-element with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package artyuum/html-element contains the following files

Loading the files please wait ....