Download the PHP package sebastopolys/ginsenghtml without Composer

On this page you can find all versions of the php package sebastopolys/ginsenghtml. 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 ginsenghtml

Ginseng Html is a html engine for PHP

Provides PHP functions you can use on your code, in order to build large & complex html structures in a more simple, effective and organized way.

Installation

composer require sebastopolys/ginsenghtml

Save the ginsenghtml.php file somewere in your PHP application.

Usage:

After installing, instantiate ginsenghtml class in the constructor of a class:

[!NOTE] ginsenghtml() is a static class so it needs to be instantiated only once, on the first template file that is loaded.

Because functions are used to build html elements, it is necessary to call the html functions also.

Add the necessary html functions on each template file.

If you change namespace of ginsenghtml class to match your project namespace, it is not neccesary to add use function declaration.

After this, html functions will become available in further methods of your class:

Html functions:

Function names make reference to the Html tag to be used on the Html the function outputs. I.e:

Will output the following html:

Using the html functions

In the above example, a paragraph is built by passing a string to the function

It is also possible to pass an array to the function and add attributes to the html element

This will print out:

Additional functions: close()

Note that on the above example, there is no content inside the html, neither is a closing html tag (</span> )

The additional close() function is provided in order to have more control on html elements closing and opening

Use this function to close any opened html tag:

This will output a self enclosed paragraph element:

Result:

Additional function: content()

The content() function takes a content value referenced on the given array under the 'content' index. And it uses this value to insert it within the html element

This function takes a non associative array, composed with one or more associative arrays

When the content function is called, it will include the content and close the html element with its corresponding closing tag

Usage of the content function;

Will output:

[!CAUTION] 'content' and 'tag' indexes are required when using the content() function on template files

Opened and closed html elements

There are several situations were html functions can return a self enclosed html tag or not

Without closing tag
With closing tag

Note that if any html element is printed without its closing tag, browsers will add it at the end of the <body> automatically

Print multiple elements with a single html function

It is possible to output multiple html tags using a single html function.

In order to achieve this the array passed to the function must be indexed without associative keys:

So you can build the array like this:

Giving this array to a function will print the amount of elements represented by the count of the first array on the array.

In the above sample array, it would be the count of "id" values, which is 4

Result:

Supported Html tags (functions)

head link footer header script
nav section div span h1
h2 h3 p a img
table form input label ul
li hr th tr td

Feel free to edit the ginsenghtml.php file and add any missing html tag if you need

Keys & concepts

Functions and arrays

Key of the parser is to understand that you can build the html structure either on the PHP temlate file by using the functions, or in the data arrays passed to the functions that comes from the controller.

I.e.

and:

Will both output the same html:

Nesting functions:

It is possible to nest functions inside functions:

Will output:

Nested argument arrays:

Both 'tag' and 'content' indexes are required so the content() additional function is executed recursively

Use both 'tag' and 'content' index on your arrays to create & nest html elements.

Argument arrays passed to functions

You can build the arrays passed to functions dinamically, but be aware that this can harm the loading speed of page load. Try to keep the arguments array the smaller as possible.

Changelog

Initial release

Latest Version

Author

sebastopolys


All versions of ginsenghtml with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 sebastopolys/ginsenghtml contains the following files

Loading the files please wait ....