PHPackages                             alius/tag - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alius/tag

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alius/tag
=========

Create html tags

1.0.6(9y ago)053.6k↓47.6%GPL-2.0PHPPHP &gt;=5.5

Since Jan 17Pushed 9y agoCompare

[ Source](https://github.com/vegvari/AliusTag)[ Packagist](https://packagist.org/packages/alius/tag)[ RSS](/packages/alius-tag/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)DependenciesVersions (9)Used By (0)

[![Build Status](https://camo.githubusercontent.com/5962744688de013147b8933362d0b2388cf1941e92aef535373b3cf827d511f5/68747470733a2f2f7472617669732d63692e6f72672f766567766172692f416c6975735461672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vegvari/AliusTag)

Alius Tag
=========

[](#alius-tag)

It's just a simple class to create tags.

### Basic usage

[](#basic-usage)

```
$img = new Tag('img');
print $img; //

$img->src('url')
print $img; //

$img->alt();
print $img; //

$img->alt('Cute cat')
print $img; //

$img->class('cute');
print $img; //

$img->class('dog');
print $img; //

$img->addClass('cute');
print $img; //

$div = new Tag('div');
$div->add($img);
print $div; //

$div->data('ng-class', 'test');
print $div; //

```

Use the render method or cast the class to string to get the html.

Methods
-------

[](#methods)

### Attributes

[](#attributes)

#### object attr ( string $name, mixed $value = null )

[](#object-attr--string-name-mixed-value--null-)

Change the attribute. Chainable.

```
$tag = new Tag('div');
$tag->attr('foo'); // >
$tag->attr('foo', ''); //
$tag->attr('foo', 'bar'); //

```

Preserves the original php type:

```
$tag->attr('foo', true); //
$tag->getAttr('foo'); // true

```

Html entities and double quotes are converted (only when rendered):

```
$tag->attr('foo', '"foo" \'bar\' '); //
$tag->getAttr('foo'); // "foo" 'bar'

```

#### mixed getAttr ( string $name )

[](#mixed-getattr--string-name-)

Get the attribute value.

#### bool hasAttr ( string $name )

[](#bool-hasattr--string-name-)

True if the attribute exists. Even if it's empty.

#### object deleteAttr ( string $name )

[](#object-deleteattr--string-name-)

Delete the attribute. Chainable.

#### string renderAttr ( string $name )

[](#string-renderattr--string-name-)

Get the attributes in string.

### Content

[](#content)

#### object add ( mixed $value )

[](#object-add--mixed-value-)

Add content. Chainable. The value is converted to string, null or empty string is skipped.

```
$tag = new Tag('div');
$tag->add('foo')->add('bar'); // foobar

```

#### object setContent ( mixed $value )

[](#object-setcontent--mixed-value-)

Replaces the content. Chainable.

#### bool hasContent

[](#bool-hascontent)

True if there is some content.

#### object deleteContent

[](#object-deletecontent)

Delete the content. Chainable.

#### string renderContent

[](#string-rendercontent)

Get the content string.

### Class

[](#class)

Helper methods for classes.

#### object addClass ( $values )

[](#object-addclass--values-)

Add class(es). Chainable. Null and empty string skipped. You can pass an array or string. Don't worry about whitespaces.

```
$tag = new Tag('div');
$tag->addClass('foo')-addClass('bar'); //
$tag->addClass([' a ', ' b c ']); //

```

#### object setClass ( $values )

[](#object-setclass--values-)

Replace existing classes. Chainable. You can use it with the class pseudo method via \_\_call:

```
$tag = Tag('img');
$tag->class('test); //

```

#### array getClass ()

[](#array-getclass-)

Get the classes.

#### bool hasClass ( $value )

[](#bool-hasclass--value-)

True when the class is set.

#### object deleteClass ( $values )

[](#object-deleteclass--values-)

Delete one class. Chainable. Deletes the class attribute when you delete the last class.

### Data

[](#data)

Helper methods for data attributes.

#### object data ( $name, $value = null )

[](#object-data--name-value--null-)

Set the data attribute. Chainable.

```
$tag = new Tag('div');
$tag->data('foo', 'bar'); //

```

#### mixed getData ( $name )

[](#mixed-getdata--name-)

Get the data value. Null if the data is not set.

#### bool hasData ( $name )

[](#bool-hasdata--name-)

True if there is a data attribute with this name, even if it's empty.

#### object deleteData ( $name )

[](#object-deletedata--name-)

Delete the attribute.

### Other

[](#other)

Non-existing methods are treated as attributes using the \_\_call method:

```
$tag = new Tag('img');
$tag->foo('bar')->bar('foo'); //

```

You can use this class statically:

```
$tag = Tag::anything(); //

```

There is a general factory:

##### object make ( string $tag )

[](#object-make--string-tag-)

And there are some useful helper factories:

#### object form ( string $action, $method = 'post', $token = null )

[](#object-form--string-action-method--post-token--null-)

If the form isn't get or post we change the method to post and add a \_method hidden tag:

```
$tag = Tag::form('url', 'delete');

```

```

```

If you set the token we place a \_token hidden tag:

```
$tag = Tag::form('url', 'post', 'foo bar');

```

```

```

#### object labelFor ( mixed $for, string $text = null )

[](#object-labelfor--mixed-for-string-text--null-)

You can add string or even an other tag:

```
$tag = Tag::labelFor(Tag::foo()->id('bar'), 'foobar'); // foobar

```

#### object select ( string $name, array $options = \[\] )

[](#object-select--string-name-array-options---)

Use it with option tags:

```
$tag = Tag::select('foo', [
    Tag::option('one', 1),
    Tag::option('two', 2),
    Tag::option('three', 3),
]);

```

```

    one
    two
    three

```

##### object div ( mixed $content = null )

[](#object-div--mixed-content--null-)

##### object span ( mixed $content = null )

[](#object-span--mixed-content--null-)

##### object a ( string $href, mixed $content = null )

[](#object-a--string-href-mixed-content--null-)

##### object img ( string $src )

[](#object-img--string-src-)

##### object caption ( mixed $text = null )

[](#object-caption--mixed-text--null-)

##### object input ( string $type, string $name, string $value = null )

[](#object-input--string-type-string-name-string-value--null-)

##### object checkbox ( string $name, string $value = null, $checked = false )

[](#object-checkbox--string-name-string-value--null-checked--false-)

##### object radio ( string $name, string $value = null, $checked = false )

[](#object-radio--string-name-string-value--null-checked--false-)

##### object text ( string $name, string $value = null )

[](#object-text--string-name-string-value--null-)

##### object password ( string $name )

[](#object-password--string-name-)

##### object hidden ( string $name, string $value )

[](#object-hidden--string-name-string-value-)

##### object option ( string $text, string $value = null, $selected = false )

[](#object-option--string-text-string-value--null-selected--false-)

##### object textarea ( string $name, string $value = null )

[](#object-textarea--string-name-string-value--null-)

### Hello World

[](#hello-world)

```
print Tag::html()->lang('en')
    ->add(Tag::head()
        ->add(Tag::title()->add('HTML5'))
        ->add(Tag::meta()->charset('utf-8'))
        ->add(Tag::meta()->author('Romeo Vegvari'))
    )
    ->add(Tag::body()
        ->add(Tag::div('Hello World!'))
    );

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~20 days

Total

8

Last Release

3540d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a3578488454f47f8cc2b9a458b4068ba46344edf77d476355a40b735aa88844a?d=identicon)[Romeo Vegvari](/maintainers/Romeo%20Vegvari)

---

Top Contributors

[![vegvari](https://avatars.githubusercontent.com/u/3232519?v=4)](https://github.com/vegvari "vegvari (3 commits)")

### Embed Badge

![Health badge](/badges/alius-tag/health.svg)

```
[![Health](https://phpackages.com/badges/alius-tag/health.svg)](https://phpackages.com/packages/alius-tag)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
