PHPackages                             hazbo/simpletags - 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. hazbo/simpletags

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

hazbo/simpletags
================

SimpleTags Library for parsing {various tags}

022PHP

Since Jan 28Pushed 12y ago1 watchersCompare

[ Source](https://github.com/hazbo/simpletags)[ Packagist](https://packagist.org/packages/hazbo/simpletags)[ RSS](/packages/hazbo-simpletags/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

SimpleTags
==========

[](#simpletags)

Description
-----------

[](#description)

Simpletags is exactly what it sounds like... a simple way to use tags in your PHP application. This allows you to have tags that look like this:

```
{something:other}
{date format="m/d/Y"}

{blog:entries count="5"}
Stuff here
{/blog:entries}

```

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

[](#installation)

Add `hazbo/simpletags` to your `composer.json` file

```
{
    "require" : {
        "hazbo/simpletags"
    }
}
```

`composer update`

Usage
-----

[](#usage)

You can send a config array to the constructor with the following options (these are the defaults):

```
array(
    'l_delim' => '{',
    'r_delim' => '{',
    'trigger' => '',
);
```

You can also set the delimiters and triggers via the following functions:

```
$simpletags = new SimpleTag();
$simpletags->setDelimitiers('{', '}');
$simpletags->setTrigger('foo:');
```

To parse a string of text you simply call the parse() function. The parse function accepts 3 parameters:

1. $content - The content to parse
2. \[optional\] $data - a keyed array of data to replace tag vars with (more below)
3. \[optional\] $callback - A callback that will be called for each tag.

### Normal Return

[](#normal-return)

If no callback is specified then the function will return an array. Consider this is the content you sent:

```
Hello there.

{rest:get url="http://example.com/api" type="json"}
Stuff here
{/rest:get}

Bye.

```

Parse would return this:

```
Array
(
    [content] => Hello there.

marker_0k0dj3j4nJHDj22j

Bye.
    [tags] => Array
        (
            [0] => Array
                (
                    [full_tag] => {rest:get url="http://example.com/api" type="json"}
Stuff here
{/rest:get}
                    [attributes] => Array
                        (
                            [url] => http://example.com/api
                            [type] => json
                        )

                    [segments] => Array
                        (
                            [0] => rest
                            [1] => get
                        )

                    [content] =>
Stuff here

                    [marker] => marker_0k0dj3j4nJHDj22j
                )

        )

)

```

### Using the Data Array

[](#using-the-data-array)

The data array is a keyed array who's contents will replace tags with the same name. Example:

```
{foo:bar}

```

Would be replaced with "Hello World" when the following data array is sent to the parse function:

```
$data['foo']['bar'] = "Hello World"

```

You can use tag pairs to loop through data as well:

#### Tag:

[](#tag)

```
{books}
{title} by {author}
{/books}

```

#### Data

[](#data)

```
$data = array(
    'books' => array(
        array(
            'title' => 'PHP for Dummies',
            'author' => 'John Doe'
        ),
        array(
            'title' => 'CodeIgniter for Dummies',
            'author' => 'Jane Doe'
        )
    )
);
```

#### Resulting Output

[](#resulting-output)

```
PHP for Dummies by John Doe
CodeIgniter for Dummies by Jane Doe

```

### Callbacks

[](#callbacks)

The callback must be in a form that is\_callable() accepts (typically array(object, method)). The callbac function should take 1 parameter (an array).

The callback will be sent the tag information in the form of an array. Consider the following

```
{rest:get url="http://example.com/api" type="json"}
Stuff here
{/rest:get}

```

Would send the callback function the following array:

```
Array
(
    [full_tag] => {rest:get url="http://example.com/api" type="json"}
Stuff here
{/rest:get}
    [attributes] => Array
        (
            [url] => http://example.com/api
            [type] => json
        )

    [segments] => Array
        (
            [0] => rest
            [1] => get
        )

    [content] =>
Stuff here

    [marker] => marker_0k0dj3j4nJHDj22j
)

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4755952c71b2d702aaaf3799c3e9b6cbf30f2d1fb959e7de040b0d8e3b5c85ae?d=identicon)[hazbo](/maintainers/hazbo)

---

Top Contributors

[![dhrrgn](https://avatars.githubusercontent.com/u/149921?v=4)](https://github.com/dhrrgn "dhrrgn (8 commits)")[![ericlbarnes](https://avatars.githubusercontent.com/u/116662?v=4)](https://github.com/ericlbarnes "ericlbarnes (1 commits)")

### Embed Badge

![Health badge](/badges/hazbo-simpletags/health.svg)

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

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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