PHPackages                             ermac/text\_builder - 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. ermac/text\_builder

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

ermac/text\_builder
===================

Create various dynamic texts

21PHP

Since Mar 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/RezaDezhhoot/text_builder)[ Packagist](https://packagist.org/packages/ermac/text_builder)[ RSS](/packages/ermac-text-builder/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

TextBuilder
===========

[](#textbuilder)

TextBuilder is a Laravel package for create various dynamic texts.

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

[](#installation)

Use the package manager [composer](https://getcomposer.org/) to install TextBuilder.

```
composer require ermac/text_builder
```

Put provider inside the config/app.php file and Service Providers section

```
'providers' => [
    ...
    Ermac\TextBuilder\TextBuilderServiceProvider::class,

```

And then enter in the alias class

```
'aliases' => [
    ...
    'TextBuilder' => Ermac\TextBuilder\TextBuilderFacade::class,
```

And run command

```
php artisan vendor:publish --provider="Ermac\TextBuilder\TextBuilderServiceProvider" --tag=config
```

Configuration
-------------

[](#configuration)

Inside the config path and textBuilder.php file You can specify the symbol between which your parameters are to be placed

```
'sign' => '%'
```

You can also define parameters globally and explain each one

```
'global_parameters' => [
        'date' => 'description',
        'time',
    ]
```

Usage
-----

[](#usage)

In the model where you want to define parameters, first call the HasParams trait

```
use Ermac\TextBuilder\HasParams;
class User extends Authenticatable
{
    ...
    use HasParams;
}
```

### Parameters

[](#parameters)

In the model where you want to define parameters, first call the params property, then enter the desired parameters in the params property. Note that the defined parameters must be the same as the names of the columns in the database table.

```
protected $params = [
    'name' => 'description',
    'email',
     ];
```

If you want to enter all the columns, you can use the \* sign

```
protected $params = [
    '*'
     ];
```

And if you want to ignore a number of columns, you can use the ^ symbol.

```
protected $params = [
    '^password,created_at'
     ];
```

### Relations

[](#relations)

You can use one-to-one or one-to-many or many-to-many relationship methods to configure such parameters.

#### one-to-one

[](#one-to-one)

```
protected $params = [
       'wallet-balance',
    ];

public function wallet()
{
    return $this->hasOne(Wallet::class);
}
```

#### one-to-many

[](#one-to-many)

```
protected $params = [
       'orders-tracking_code',
       'orders-price',
       'orders-product-title',
    ];

public function orders()
{
    return $this->hasMany(Order::class);
}
```

You can use different relationships to infinity

##### Order.php

[](#orderphp)

```
class Order extends Model
{
    public function product()
    {
        return $this->belongsTo(Product::class);
    }
}
```

#### many-to-many

[](#many-to-many)

```
protected $params = [
      'roles-name'
    ];

public function roles()
{
    return $this->belongsToMany(Role::class,'user_has_roles');
}
```

Methods
-------

[](#methods)

Get parameters

```
$params = TextBuilder::getParameters();
```

output

```
Array (
    [0] => Array ( [param] => %orders_price% [description] => )
    [1] => Array ( [param] => %users_name% [description] => description )
    [2] => Array ( [param] => %users_email% [description] => )
    [3] => Array ( [param] => %users_wallet-balance% [description] => )
    [4] => Array ( [param] => %users_orders-price% [description] => )
    [5] => Array ( [param] => %date% [description] => description )
    [6] => Array ( [param] => %time% )
)
```

Do this if you want to get the parameters of certain models

```
$params = TextBuilder::getParameters([Model::class,...]);
```

And if you want to ignore parameters, you can use this argument

```
$params = TextBuilder::getParameters('',\App\Models\User::class , ...);
```

Now

```
$text = "Hi %users_name%, your wallet balance is $ %wallet-balance%";
$text = TextBuilder::make($text,\App\Models\User::find(1) );
```

output

```
"Hi james, your wallet balance is $ 1000";
```

You can use this mode if you need to enter multiple models

```
$text = TextBuilder::make($text,[\App\Models\User::find(1),\App\Models\Order::find(1)] );
```

And if you need to ignore a parameter, you can use this mode

```
$text = TextBuilder::make($text,[\App\Models\User::find(1),\App\Models\Order::find(1)] ,['users_password',...]);
```

If you need to manually enter the parameters like the global parameters, you can use the following method

```
$text = TextBuilder::set($text,['time',...],[\Carbon\Carbon::make(now())->format('H:m'),...]);
```

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 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://www.gravatar.com/avatar/6d55c5c2019439ae11d69d4761802bcda324e9762a25291606bce7b1f7548955?d=identicon)[RezaDezhhoot](/maintainers/RezaDezhhoot)

---

Top Contributors

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

---

Tags

laravel-packagetext

### Embed Badge

![Health badge](/badges/ermac-text-builder/health.svg)

```
[![Health](https://phpackages.com/badges/ermac-text-builder/health.svg)](https://phpackages.com/packages/ermac-text-builder)
```

###  Alternatives

[justcoded/wordpress-theme-boilerplate

WordPress theme boilerplate with better code structure and OOP support.

563.9k1](/packages/justcoded-wordpress-theme-boilerplate)

PHPackages © 2026

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