PHPackages                             emreuyguc/easytag - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. emreuyguc/easytag

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

emreuyguc/easytag
=================

Simple html Tag creator.

1.0.0(4y ago)115GPL-3.0-onlyPHPPHP &gt;=7.4

Since Oct 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/emreuyguc/php-easytag-package)[ Packagist](https://packagist.org/packages/emreuyguc/easytag)[ Docs](https://github.com/emreuyguc/php-easytag)[ RSS](/packages/emreuyguc-easytag/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

php-easytag
===========

[](#php-easytag)

Html/Xml markup Tag Creator for Php.

It is an easy markup tag creation tool with PHP. You can use helper methods with the **Tag** object and build it whenever you want. If you wish, you can have your tag build instantly by using the **TagBuild** extended class.

For self closing elements in html tags, I defined self closing tags in an extended **HtmlTag** class and provided instant rendering with the use of TagBuilder.

Usage
=====

[](#usage)

#### Tag Object

[](#tag-object)

- **Init**

```
$tag = new Tag(string $name);
```

- **Fast Init**

```
Tag::@tagname(array|string|Tag $element) : Tag
```

- **Element Methods**

```
$tag->setElements(array $elements);
```

```
$tag->appendElement(Tag|String $elements);
```

```
$tag->prependElement(Tag|String $elements);
```

- **Attribute Methods**

```
$tag->setAttrs(array $attrs);
```

```
$tag->addAttr(string $attr, string $value);
```

```
$tag->removeAttr(string $attr);
```

- **Build methods**

```
$tag->setSelfClosing(bool $isPaired = TRUE);
```

```
$tag->build(): string
```

```
$tag->render(): void
```

#### Fast Tag Builder

[](#fast-tag-builder)

```
TagBuild::@tagname(array|string|Tag $element) : string
```

#### Html Tag Builder

[](#html-tag-builder)

```
HtmlTag::@tagname(array|string|Tag $element) : string
```

or with attributes

```
HtmlTag::@tagname(array $attrs, array|string|Tag $element) : string
```

Features
========

[](#features)

- All methods can be chained.
- Tag Object have static method for fast tag init. Just call static method with your tag name. return type Tag
- HtmlTag and TagBuild are abstract class and just call static method with your tag name. Elements builds at runtime and only string returns.
- Tag Object and TagBuild fast init feature can take array ,string and tag objects. If you don't like using arrays, you can add infinite parameters of tag or string type and the class defines these parameters as elements.
- When using Tag Object fast init or using TagBuild, if the first parameter is array\[key=&gt; value\] the class will automatically define attributes.
- In version 1.0.0, all outputs go through the beautify process. This feature currently does not have any settings.

Examples
========

[](#examples)

#### Object Example

[](#object-example)

```
$data = [
	[
		'price' => '15.95',
		'name' => 'Cap',
		'code' => 'C1234'
	],
	[
		'price' => '23.95',
		'name' => 'Tshirt',
		'code' => 'T1534',
	]
];

$products = new Tag('products');
$products->addAttr('last-date','17.08.2021');

foreach ($data as $product_detail){
	$product = new Tag('product');

	foreach ($product_detail as $key => $value){
		$product->appendElement((new Tag($key))->appendElement($value));
	}

	$products->appendElement($product);
}

$products->render();
```

- Output

```

		15.95
		Cap
		C1234

		23.95
		Tshirt
		T1534

```

#### Fast Render Example

[](#fast-render-example)

```
echo TagBuild::config(
	TagBuild::server('localhost'),
	TagBuild::port('8080'),
	TagBuild::db('tagV1'),
	TagBuild::user('root'),
	TagBuild::pass('toor'),
);
```

- OUTPUT

```

	localhost
	8080
	tagV1
	root
	toor

```

#### Easy Html for self closing tags

[](#easy-html-for-self-closing-tags)

```
echo HtmlTag::html(
	HtmlTag::head(
		HtmlTag::title('Html Example'),
		HtmlTag::meta(['author' => 'emreuyguc']),
		HtmlTag::link(['rel' => 'stylesheet','href' => 'your.css']),
	),
	HtmlTag::body(
		HtmlTag::div(['class' => 'content'],'hello',' world'),
		HtmlTag::script(['src' => 'your.js'])
	)
);
```

- OUTPUT

```

		Html Example

		hello world

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1676d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/998bfee719bb7fec056c6aecfded8ac88195951e15127a16b17c0512765592a3?d=identicon)[emreuyguc](/maintainers/emreuyguc)

---

Top Contributors

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

---

Tags

xmlhtmltaghtml-generatortag creatortag generatorhtml creator

### Embed Badge

![Health badge](/badges/emreuyguc-easytag/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[imangazaliev/didom

Simple and fast HTML parser

2.2k2.3M64](/packages/imangazaliev-didom)[querypath/querypath

HTML/XML querying and processing (like jQuery)

8197.0M27](/packages/querypath-querypath)[rumenx/php-sitemap

Framework-agnostic Sitemap generator for PHP, Laravel, and Symfony.

1.3k15.1k1](/packages/rumenx-php-sitemap)[rct567/dom-query

DomQuery is a PHP library that allows easy 'jQuery like' DOM traversing and manipulation

134261.0k4](/packages/rct567-dom-query)[gravitypdf/querypath

PHP library for HTML(5)/XML querying (CSS 4 or XPath) and processing (like jQuery) with PHP 7.1 to 8.5 support

281.2M1](/packages/gravitypdf-querypath)

PHPackages © 2026

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