PHPackages                             singlequote/laravel-text-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. singlequote/laravel-text-parser

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

singlequote/laravel-text-parser
===============================

A package to replace words in a text with values from a array. Also supports aliases and excluded properties

2.0.0(5y ago)0199MITPHPPHP ^8.0

Since Jun 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/singlequote/laravel-text-parser)[ Packagist](https://packagist.org/packages/singlequote/laravel-text-parser)[ Docs](https://github.com/SingleQuote/laravel-text-parser)[ RSS](/packages/singlequote-laravel-text-parser/feed)WikiDiscussions master Synced 1w ago

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

An easy laravel text parser
===========================

[](#an-easy-laravel-text-parser)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c39942bba360276b3e8c85d2df01e014fe30840e1377e2f35027448868fc2745/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696e676c6571756f74652f6c61726176656c2d746578742d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/singlequote/laravel-text-parser)[![Total Downloads](https://camo.githubusercontent.com/a18a0821edc160ccd37bad1e9cead987ad675404aa576447119ac59ab85a1cb1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696e676c6571756f74652f6c61726176656c2d746578742d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/singlequote/laravel-text-parser)

A package to replace words in a text with values from a array. Also supports aliases and excluded properties.

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

[](#installation)

You can install the package via composer:

```
composer require singlequote/laravel-text-parser
```

Basic Usage
-----------

[](#basic-usage)

```
Parser::text('Hello [who]')->values(['who' => 'world'])->parse(); // Hello world

Parser::text('Hello {who}')->values(['who' => 'world'])->tags(['{', '}'])->parse(); // Hello world

Parser::text('Hello [who]')->values(['who' => 'world'])->exclude(['who'])->parse(); // Hello [who]

Parser::text('Hello [what]')->values(['who' => 'world'])->aliases(['what' => 'who'])->parse(); // Hello world
```

### Using arrays as values

[](#using-arrays-as-values)

```
$values = [
    'user' => [
        'name' => [
            'first_name' => 'Foo',
            'last_name' => 'Bar'
        ],
        'email' => 'example@example.com'
    ]
];

$input = "[user.name.first_name][user.name.last_name] - [user.email]";

$result = Parser::text($input)->values($values)->parse();
```

will generate `FooBar - example@example.com`

Available methods
-----------------

[](#available-methods)

All methods can be chained together like `text()->values()->aliases()` and can be in any order. But you always have to start with the `text()` function.

### text

[](#text)

This sets the string you want to parse

```
    $parser = Parser::text('string')
```

### values

[](#values)

This sets the values to use while parsing. Must be a array

```
    $parser->values([]);
```

### tags

[](#tags)

Tags are the characters around the keys you want to parse. Default `[` and `]`

```
    $parser->tags(['{','}']);
```

### exclude

[](#exclude)

Sets the keys which are excluded from parsing

```
    $parser->exclude(['key', 'key2']);
```

### aliases

[](#aliases)

Sets the aliases. Aliases can be used to map a value to a different name. So for example you can set the aliases to `['name' => 'username']` to map `username` to `name`

```
    $parser->exclude(['alias', 'value key']);
```

### parse

[](#parse)

Parses the text and returns the parsed string

```
    $parser->exclude(['alias', 'value key']);
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Quotec](https://github.com/SingleQuote)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~15 days

Total

2

Last Release

1860d ago

Major Versions

1.0.0 → 2.0.02021-07-13

PHP version history (2 changes)1.0.0PHP ^7.1

2.0.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![wimurk](https://avatars.githubusercontent.com/u/14072334?v=4)](https://github.com/wimurk "wimurk (6 commits)")

---

Tags

laravelparsertextSingleQuote

### Embed Badge

![Health badge](/badges/singlequote-laravel-text-parser/health.svg)

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

###  Alternatives

[creof/geo-parser

Parser for geography coordinate strings

614.6M15](/packages/creof-geo-parser)[pherum/laravel-bbcode

Parse your BBCode easy with this library.

2532.2k](/packages/pherum-laravel-bbcode)

PHPackages © 2026

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