Download the PHP package amsrafid/tagger without Composer

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

Tagger

One of the most flexible html view builder for php. It builds view in php file using same naming convention of html tag and attributes.

Installation

This is a composer package. So, require this package in the composer.json of your php/framework project or run the command bellow,

composer require amsrafid/tagger

Basic use

Very easy to use. Attribute and tag name is same as normal html. Most notable fact is that sudo or short name is also worked as normal HTML attributes.

\Html\Tag::{Tag name}([
    'i/id' => 'id-name',
    'c/cls/class' => 'class-name',
    'd-./_./*./data-.' => 'data-value',
    'b/body/txt/text' => string|array|number|bool|function(){} /* tag body*/
    ...
]);

Array key refers attribute name and key value as attribute value.\ Note: Data attribue is also handled with sudo as like [d-name/_name/*name].\ In all cases above, attribute name will be data-name.

Attribute 'body':

Attribute body is the nested part of a tag. Body can be of five types. String or number is basic type. Special types are,

Sudo attributes are available

List of sudo attribute is given bellow.

a       =   alt,
ac      =   action,
c       =   class,
cls     =   class,
cont        =   content,
cs      =   colspan,
d       =   disabled,
dt      =   datetime,
f       =   for,
fa      =   formaction,
h       =   href,
i       =   id,
ln      =   lang,
m       =   method,
mx      =   max,
mn      =   min,
mxlen       =   maxlength,
mnlen       =   minlength,
mt      =   muted,
n       =   name,
p       =   placeholder,
pt      =   pattern,
r       =   required,
rs      =   rowspan,
rw      =   rows,
s       =   src,
sc      =   selected,
st      =   style,
t       =   type,
v       =   value,
val     =   value

Preset functionality

Tagger allows preset of attributes and wrapper. It reduces using of same attribute and wrapping on same tag.

Preset attributes for identical tag

Preset functionality works on common attribute value using set method. Here, preseting can be stoped by using stopSet method that accepts string or array of tag name or empty for destroy all.

Tag::set([
    'input' => [
        'c/cls/class' => 'form-control mt-2',
        ...
    ],
    'textarea' => '@input',     /* Same as input tag */
    ...
]);

Tag::input(['type' => 'text']);
Tag::input(['type' => 'number']);
Tag::textarea(['b' => 'Text area', 'c' => 'text-danger']);

Tag::stopSet();

Output:

<input type = "text" class = "form-control mt-2" />
<input type = "number" class = "form-control mt-2" />
<textarea class = "text-danger form-control mt-2">Text area</textarea>

Preset wrapper for identical tag

Similar with set wrapping functionality works on common wrapper value, using wrap method. Here also, tag wrapping can be stoped by using stopWrap method that accepts string or array of tag name or empty for destroy all.

Tag::wrap([
    'input' => ['div', ['c' => 'col-md-6', ...]],
    'textarea' => 'div',
    'select' => '@input'    /* Same as input tag */
    ...
]);

Tag::input(['t' => 'text']);
Tag::textarea();
Tag::select(['b' => ['option' => ['one', 'two']]]);

Tag::stopWrap(['textarea']);    /* OR Tag::stopWrap('textarea'); */
Tag::textarea("Text area value");

Output:

<div class = "col-md-6"><input type = "text" /></div>
<div><textarea></textarea></div>
<div class = "col-md-6">
    <select>
        <option>one</option>
        <option>two</option>
    </select>
</div>
<textarea>Text area value</textarea>

Special use

Label

Automatic <label> tag can be added before any tag, using label attribute. If label containing tag has a wrapper preset, a label tag will be created into the wrapper before this.

Tag::wrap([
    'input' => ['div', ['c' => 'col-md-6 mb-2']]
]);

Tag::input(['t' => 'text', 'i' => 'name', 'label' => 'Name *', 'p' => "Name"]);
Tag::input(['t' => 'number', 'i' => 'age', 'label' => 'Age *', 'p' => "Age"]);

Output

<div class="col-md-6 mb-2">
    <label for="name">Name *</label>
    <input id="name" type="text" placeholder = "Name">
</div>
<div class="col-md-6 mb-2">
    <label for="age">Age *</label>
    <input id="age" type="number" placeholder = "Age">
</div>

Table

Here, html table is able to be generated dynamically. Where, body can be passed an array with key as tag name and key value as normal array for tag body.

$arrs = [
    ['id' => 24, 'name' => 'HTML'],
    ['id' => 33, 'name' => 'CSS'],
    ['id' => 49, 'name' => 'JAVASCRIP']
];

Tag::table(['border' => '1', 'b' => function() use($arrs) {
    Tag::tr(['b' => ['th' => ['#', 'ID', 'Name']]]);
    Tag::tr(['foreach' => $arrs, 'offset' => 'i'
        'b' => ['td' => ['@i', '@id', '@name']]
    ]);
}]);

Output

<table border = "1">
    <tr><th>#</th><th>ID</th><th>Name</th></tr>
    <tr><td>1</td><td>24</td><td>HTML</td></tr>
    <tr><td>2</td><td>33</td><td>CSS</td></tr>
    <tr><td>3</td><td>49</td><td>JAVASCRIP</td></tr>
</table>

Control statement

Control statement acts as like normal foreach/if/elseif/else here. Control statement uses as attribute.

foreach:

Act like normal foreach in php. Here, offset, start respectively used for loop array/object offset, and from which value offset count will be started.

Tag::ul(['if' => $arrs, 'b' => function() use($arrs) {
    Tag::li([
        'foreach' => $arrs, 'offset' => 'i',
        'if' => '@id > 24',
        'v' => '@id', 'b' => '@i. @name'
    ]);
}]);

Output

<ul>
    <li value="33">1. CSS</li>
    <li value="49">2. JAVASCRIP</li>
</ul>

@id -> @{array key name}.\ Able to capture in any attribute value.

Special Attributes: Attributes given bellow are useful only iff foreach attribute is present.

if:

Normal if statement like php.\ Note: Attribute then is allowed as same way of if statement in foreach special attributes section. But, only array type value is working here.

$var = 10;
Tag::span(['if' => $var > 10, 'b' => 'Var is greater than 10']);

Normal use:

if($var > 10)
    echo "<span>Var is greater than 10</span>

elseif:

Normal elseif statement like php. Here, this condition will only work iff if statment is present before this.\ Note: Attribute then is allowed as same way of if statement.

Tag::span(['elseif' => $var > 5, 'b' => 'Var is greater than 5']);

Normal use:

if ($var > 10)
    ...
else if ($var > 5)
    echo "<span>Var is greater than 5</span>

else:

Normal else statement like php. Value should be given as true. Here, this condition will only work iff if or elseif statment is present before this.\ Note: Attribute then is not allowed here.

Tag::span(['else' => true, 'b' => 'Var is less than 5']);

Normal use:

if ($var > 10)
    ...
else
    echo "<span>Var is less than 5</span>

Authors

Initially development - Sadman Rafid

License

The tagger is open-source software licensed under the MIT license.


All versions of tagger with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.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 amsrafid/tagger contains the following files

Loading the files please wait ....