PHPackages                             undercloud/leaf - 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. undercloud/leaf

ActiveLibrary

undercloud/leaf
===============

PHP DOM Generator

113PHP

Since Apr 10Pushed 10y ago1 watchersCompare

[ Source](https://github.com/undercloud/leaf)[ Packagist](https://packagist.org/packages/undercloud/leaf)[ RSS](/packages/undercloud-leaf/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

leaf
====

[](#leaf)

PHP DOM Generator

\##install `composer require unercloud/leaf`

\##simple example

```
	$l = new \Undercloud\Leaf();

	$l->el('html')
		->el('body')
			->el('h1#id.classname','Heading')->end
			->el('p',array('class' => 'article'),'Lorem ipsum...')->end
			->el('input:text',array('value'=>'text'))
		->end
	->end;

	echo $l;
```

\##constructor

```
	$l = new \Undercloud\Leaf(
		array(
			//format tree
			'format' => true,
			//indent in formatted tree, default two spaces
			'indent' => '  ',
			//define own single tags
			'selfclosing' => array(...)
		)
	);
```

\##methods **el** - create element

```
$l->el('tag')
```

or

```
$l->el('tag','text')
```

or

```
$l->el('tag',array $attr)
```

or

```
$l->el('tag',array $attr,'text')
```

You can combine tag with #id and .classname shortcut e.g.

```
$l->el('span#id.classname.anotherclass')
```

Input\[type\] attr helper for button,checkbox,file,hidden,image,password,radio,reset,submit,text e.g.

```
$l->el('input:text')
```

Single attr helper for 'checked','disabled','readonly','required','multiple e.g.

```
$l->el('select:multiple')
```

**text** - create text node

```
$l->text('any content')
```

**raw** - add raw data wihout escaping

```
$l->raw('raw content')
```

**end** - close tag

```
$l->end() // or $l->end
```

\##helpers **init** - create instance

```
Undercloud\Leaf::init($opt = array())
```

**escape** - escape special chars

```
Undercloud\Leaf::escape($s)
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/920a45a1bd1af5960cf6781cd2d8831ebfe2890c1077210667802afa109d8d13?d=identicon)[undercloud](/maintainers/undercloud)

### Embed Badge

![Health badge](/badges/undercloud-leaf/health.svg)

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

PHPackages © 2026

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