PHPackages                             ayeo/parser - 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. ayeo/parser

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

ayeo/parser
===========

Replace placeholders with proper data

022.8k↑64.3%1PHP

Since Jun 6Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ayeo/parser)[ Packagist](https://packagist.org/packages/ayeo/parser)[ RSS](/packages/ayeo-parser/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/52c5eb6745a2fb4eede83df46802c187eac0c9719d41623e08fcc4667ca5ba96/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6179656f2f7061727365722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ayeo/parser)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c461cab879d2fdcc26d7675b70f0d2110d4b01eb87478e2a98473d73ac49e8b5/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6179656f2f7061727365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ayeo/parser/build-status/master)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](license.md)[![Code Coverage](https://camo.githubusercontent.com/b24d52f2c4de7556574346d286045e423ac0b10b139e3dacd86cb9c1b57b9af2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6179656f2f7061727365722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ayeo/parser/?branch=master)

Simple placeholder parser
=========================

[](#simple-placeholder-parser)

Parser replaces specific placeholders with proper data.

Basic usage
===========

[](#basic-usage)

Let's take a look at the simplest possible example:

```
$parser = new Parser;
$string = "Hello {{name}}!";
$parser->parse($string, ['name' => 'Nikola Tesla']); //returns: Hello Nikola Tesla!
```

Of course you may use object instead of primitive array

```
$parser = new Parser;

$customer = new Customer;
$customer->name = 'Nikola Tesla';

$string = "Hello {{customer.name}}!";
$parser->parse($string, ['customer' => $customer]); //returns: Hello Nikola Tesla!
```

Parser is smart enough to access private properties using getters.

It also supports nested objects as well

```
$parser = new Parser;

$customer = new Customer;
$address = new Address('Green Alley', 12, 'London', 'LN4 4GD', 'United Kingdom');
$customer->setAddress($address);

$string = "{{customer.address.street}}";
$parser->parse($string, ['customer' => $customer]); //returns: Green Alley
```

Nested array are also welcome

```
$parser = new Parser();
$data = ['user' =>  ['supervisor' => ['name' => 'Harry']]];
$parser->parse('Hi {{user.supervisor.name}}!', $data); //returns: Hi Harry!
```

Use custom embrace string
=========================

[](#use-custom-embrace-string)

By default Parser uses "{{" as open string and "}}" as close string. You can set your own embrace strings using method

```
$parser = new Parser();
$parser->setEmbraceStrings("*", "*");
$parser->parse("All *fruit* are *color*.", ["fruit" => "oranges", "color" => "orange"]);
//returns "All oranges are orange."
```

or using constructor

```
$parser = new Parser("", "*", "*");
```

Note, embrace strings can not contains # char.

Formatting
==========

[](#formatting)

Sometimes you need to use additional formatting for specific objects. The great example is DateTime. The best way to achieve this goal is use adapter pattern (or decorator) for your object. The parser shouldnt be able to do that for you.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/60191?v=4)[ayeo](/maintainers/ayeo)[@ayeo](https://github.com/ayeo)

---

Top Contributors

[![ayeo](https://avatars.githubusercontent.com/u/60191?v=4)](https://github.com/ayeo "ayeo (2 commits)")

### Embed Badge

![Health badge](/badges/ayeo-parser/health.svg)

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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