PHPackages                             decodelabs/tagged - 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. decodelabs/tagged

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

decodelabs/tagged
=================

PHP markup generation without the fuss

v0.21.3(7mo ago)611.6k↓100%27MITPHPPHP ^8.4CI passing

Since Sep 10Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/decodelabs/tagged)[ Packagist](https://packagist.org/packages/decodelabs/tagged)[ RSS](/packages/decodelabs-tagged/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (86)Used By (7)

Tagged
======

[](#tagged)

[![PHP from Packagist](https://camo.githubusercontent.com/a62611e36a585a3bb5c1ca60e7b0ddb44a5d6fef55bed4ed1cc9f7f62e3b8f69/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465636f64656c6162732f7461676765643f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/tagged)[![Latest Version](https://camo.githubusercontent.com/e1a9c36cad8271ddd98e535b9ccbce243392acfb0432dc30f70d5750a532afbf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465636f64656c6162732f7461676765642e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/tagged)[![Total Downloads](https://camo.githubusercontent.com/7675706e95adbce64b9238ac3d3e43cb1810c4437a0d71f14db2feec925b17bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465636f64656c6162732f7461676765642e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/tagged)[![GitHub Workflow Status](https://camo.githubusercontent.com/c091948e242ceca17b21baeb152b91b44a6b941e00771cd3fd1a66693c796f5f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465636f64656c6162732f7461676765642f696e746567726174652e796d6c3f6272616e63683d646576656c6f70)](https://github.com/decodelabs/tagged/actions/workflows/integrate.yml)[![PHPStan](https://camo.githubusercontent.com/e25c14ce011edabdd0fbd2e10415b41cc5d66ed11ef3e5b7edd074c5bdd35a2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c6174)](https://github.com/phpstan/phpstan)[![License](https://camo.githubusercontent.com/886d7d01a8f1bba96e212ca2833a534af4cee36a425519aaa0093f9fe6d6052f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465636f64656c6162732f7461676765643f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/tagged)

### PHP markup generation without the fuss.

[](#php-markup-generation-without-the-fuss)

Tagged provides a simple, powerful and beautiful way to create HTML markup without the spaghetti.

---

Installation
------------

[](#installation)

This package requires PHP 8.4 or higher.

Install via Composer:

```
composer require decodelabs/tagged
```

Usage
-----

[](#usage)

HTML markup
-----------

[](#html-markup)

Generate markup using a simple, flexible interface.

```
use DecodeLabs\Tagged as Html;

echo Html::{'div.my-class#my-id'}(
    content: 'This is element content',
    title: 'This is a title'
);
```

...creates:

```
This is element content
```

Create individual tags without content:

```
use DecodeLabs\Tagged as Html;

$tag = Html::tag('div.my-class');

echo $tag->open();
echo 'Content';
echo $tag->close();
```

Wrap HTML strings to be used where an instance of `Markup` is needed:

```
use DecodeLabs\Tagged as Html;

$buffer = Html::raw('My span');
```

Dump script data to Html:

```
yield Html::script(
    Html::raw(json_encode( $some_data )),
    type: 'application/json'
);
```

Prepare arbitrary input for Markup output:

```
use DecodeLabs\Tagged as Html;

$markup = Html::wrap(
    function() {
        yield Html::h1('My title');
    },
    [Html::p(['This is ', Html::strong('mixed'), ' content'])]
);
```

### Attributes

[](#attributes)

Set attributes inline:

```
use DecodeLabs\Tagged as Html;

echo Html::{'div[data-attr=foo]'}('This is a div with an attribute');
```

Set attributes via an array:

```
use DecodeLabs\Tagged as Html;

echo Html::{'div'}(
    content: 'This is a div with an attribute',
    dataAttr: 'foo'
);
```

### Nesting

[](#nesting)

You can nest elements in multiple ways:

```
use DecodeLabs\Tagged as Html;

// Pass in nested elements via array
echo Html::div([
    Html::{'span.inner1'}('Inner 1'),
    ' ',
    Html::{'span.inner2'}('Inner 2')
]);

// Return anything and everything via a generator
echo Html::div(function($el) {
    // $el is the root element
    $el->addClass('container');

    // Nest elements with a single call
    yield Html::{'header > h1'}('This is a header');
    yield Html::p('This is a paragraph');

    // Set attributes inline
    yield Html::{'p[data-target=open]'}('Target paragraph');

    // Generator return values are rendered too
    return Html::{'div.awesome'}('This is awesome!');
});
```

### Time and date

[](#time-and-date)

Format and wrap dates and intervals

```
use DecodeLabs\Tagged\Time;

// Custom format
Time::format('now', 'd/m/Y', 'Europe/London');

// Locale format
// When timezone is true it is fetched from Cosmos
Time::locale('now', 'long', 'long', true);

// Locale shortcuts
Time::dateTime('tomorrow'); // medium
Time::longTime('yesterday');
Time::shortDate('yesterday');
// ...etc

// Intervals
Time::since('yesterday'); // 1 day ago
Time::until('tomorrow'); // 1 day from now
Time::sinceAbs('yesterday'); // 1 day
Time::untilAbs('yesterday'); // -1 day
Time::between('yesterday', 'tomorrow'); // 1 day
```

### Media embeds

[](#media-embeds)

Normalize embed codes shared from media sites:

```
use DecodeLabs\Tagged\Embed\Video;

echo Video::parse('https://www.youtube.com/watch?v=RG9TMn1FJzc');
```

Components
----------

[](#components)

Tagged also supports a higher level component abstraction allowing for more complex markup generation via the same interface. Components are called using an `@name` syntax:

```
use DecodeLabs\Tagged as Html;

echo Html::{'@list'}($iterable, 'div.container', 'div.item', function($item) {
    return Html::{'span'}($item);
});

echo Html::{'@img'}('path/to/image.jpg', 'alt text');
```

See the [components](./src/Tagged/Component) directory for a list of available components.

Licensing
---------

[](#licensing)

Tagged is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance72

Regular maintenance activity

Popularity29

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.6% 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 ~26 days

Recently: every ~16 days

Total

84

Last Release

232d ago

PHP version history (5 changes)v0.5.0PHP ^7.2

v0.9.0PHP ^7.2|^8.0

v0.14.0PHP ^8.0

v0.14.12PHP ^8.1

v0.16.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a241d64d12b3b5ee94197862ec1ec30b82ed2efa34a0cd7f4c3565a021daddd?d=identicon)[betterthanclay](/maintainers/betterthanclay)

---

Top Contributors

[![betterthanclay](https://avatars.githubusercontent.com/u/1273586?v=4)](https://github.com/betterthanclay "betterthanclay (569 commits)")[![MikeiLL](https://avatars.githubusercontent.com/u/6392263?v=4)](https://github.com/MikeiLL "MikeiLL (1 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")

---

Tags

htmlmarkupphptagsgeneratorhtmlmarkup

### Embed Badge

![Health badge](/badges/decodelabs-tagged/health.svg)

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

###  Alternatives

[okipa/laravel-table

Generate tables from Eloquent models.

56752.8k](/packages/okipa-laravel-table)[airmanbzh/php-html-generator

PHP html generator

7973.8k5](/packages/airmanbzh-php-html-generator)[shish/microhtml

A minimal HTML generating library

1142.1k2](/packages/shish-microhtml)[okipa/laravel-form-components

Ready-to-use and customizable form components.

198.0k1](/packages/okipa-laravel-form-components)

PHPackages © 2026

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