PHPackages                             eighteen73/laravel-tokens - 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. eighteen73/laravel-tokens

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

eighteen73/laravel-tokens
=========================

A simple package for managing Laravel token replacement from model data

1.0.4(1mo ago)0166↓33.3%[4 PRs](https://github.com/eighteen73/laravel-tokens/pulls)MITPHPPHP ^8.3CI passing

Since Oct 16Pushed 1mo agoCompare

[ Source](https://github.com/eighteen73/laravel-tokens)[ Packagist](https://packagist.org/packages/eighteen73/laravel-tokens)[ Docs](https://github.com/eighteen73/laravel-tokens)[ GitHub Sponsors](https://github.com/eighteen73)[ RSS](/packages/eighteen73-laravel-tokens/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (26)Versions (9)Used By (0)

A simple package for managing Laravel token replacement from model data
=======================================================================

[](#a-simple-package-for-managing-laravel-token-replacement-from-model-data)

[![Latest Version on Packagist](https://camo.githubusercontent.com/972b82e80bd4e0eab276a3bafb96ea7376ee881b25bfafcc24f7f7b3aa770986/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656967687465656e37332f6c61726176656c2d746f6b656e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eighteen73/laravel-tokens)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0f28bc3dfe8eaf75fac97b24aa0c8f979ec847c73366f020d3a905037ff922f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656967687465656e37332f6c61726176656c2d746f6b656e732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/eighteen73/laravel-tokens/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/75b9cfa845ae69899e45e3979b024b045b4c5fb56b8e6b5a779e000ce4e89f34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656967687465656e37332f6c61726176656c2d746f6b656e732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/eighteen73/laravel-tokens/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3750eb6348643cb35847a6862b96aa58e4707025ec51f42bb20948b4a8825d54/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656967687465656e37332f6c61726176656c2d746f6b656e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eighteen73/laravel-tokens)

You can use provides an automated way to replace tokens in user-entered text with model/relation data. This is useful for things like email templates.

All unguarded model attributes are available as tokens - as well as relation data accessed through dot notation.

When model factories are available, the factory definition attributes will also available as tokens, otherwise Model::getAttributes() will be used.

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

[](#installation)

You can install the package via composer:

```
composer require eighteen73/laravel-tokens
```

Usage
-----

[](#usage)

### List available tokens

[](#list-available-tokens)

```
$tokenManager = new Eighteen73\LaravelTokens\TokenManager();

echo $tokenManager->forModel(App\Models\User::class)->plainTokens();
```

### Replace tokens in a string

[](#replace-tokens-in-a-string)

```
$tokenManager = new Eighteen73\LaravelTokens\TokenManager();

echo $tokenManager->forModel(User::factory()->make(['email' => 'test@example.com']))
    ->replaceTokens("My email address is ##email##.");

// My email address is test@example.com
```

### Custom tokens within a model

[](#custom-tokens-within-a-model)

```
use Eighteen73\LaravelTokens\Contracts\CustomTokens;

class User extends Model implements CustomTokens
{
    public function getCustomTokens(): array
    {
        return [
            'my_custom_token' => 'Use this custom text.',
        ];
    }
}

$tokenManager = new Eighteen73\LaravelTokens\TokenManager();

echo $tokenManager->forModel(User::factory()->make())
    ->replaceTokens("Example text - ##my_custom_token##.");

// Example text - Use this custom text.
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Matt Jones](https://github.com/Muffinman)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance89

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~38 days

Total

5

Last Release

56d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7098d8dec8ddf45195f46800db66a34895b847b2ec2fbd151a4a5768fc0a87b?d=identicon)[Muffinman](/maintainers/Muffinman)

---

Top Contributors

[![Muffinman](https://avatars.githubusercontent.com/u/1319568?v=4)](https://github.com/Muffinman "Muffinman (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laraveleighteen73laravel-tokens

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/eighteen73-laravel-tokens/health.svg)

```
[![Health](https://phpackages.com/badges/eighteen73-laravel-tokens/health.svg)](https://phpackages.com/packages/eighteen73-laravel-tokens)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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