PHPackages                             bytenetizen/fast-replace - 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. bytenetizen/fast-replace

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

bytenetizen/fast-replace
========================

Fast Replace text for the Laravel framework.

1.0.0(2y ago)04MITPHPPHP ^8.1

Since Nov 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bytenetizen/fast-replace)[ Packagist](https://packagist.org/packages/bytenetizen/fast-replace)[ RSS](/packages/bytenetizen-fast-replace/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Fast Replace for Laravel
========================

[](#fast-replace-for-laravel)

Introduction
------------

[](#introduction)

Fast Replace for Laravel is a powerful and versatile package designed to streamline text manipulation tasks within the Laravel framework. Tailored for developers seeking efficiency and simplicity, this package provides a range of tools to effortlessly transform and manipulate text data in their Laravel applications.

Performance
-----------

[](#performance)

The performance comparison was made with PHP 8.2.1 and MariaDB 10.6.12 text size 62069 characters and and there were duplicate keys in the text measurements were taken 3 times and 200 iterations. The results will be Fast Replace / Fast Replace cache / Str::replace / Str::replace cache

So......

### No data received from classes

[](#no-data-received-from-classes)

Fast Replace: 15.844359 sec / 15.579132 sec / 16.032425 sec

Fast Replace and cache: 0.294150 sec / 0.259240 sec / 0.236989 sec

Str::replace: 17.547049 sec / 17.112469 sec / 16.710757 sec

Str::replace cache: 3.934095 sec / 4.042395 sec / 4.094361 sec

### We provide ready-made data

[](#we-provide-ready-made-data)

```
Fast Replace: 0.004951 sec / 0.005213 sec / 0.005084 sec

Str::replace: 0.008216 sec / 0.004294 sec / 0.006443 sec

```

Text size 498183 characters

```
Fast Replace: 0.038984 sec / 0.047993 sec / 0.038661 sec

Str::replace: 0.049044 sec / 0.050786 sec / 0.057625 sec

Fast Replace Memory usage: 1009496 bytes Peak memory usage: 1513256 bytes

Str::replace Memory usage: 1004624 bytes Peak memory usage: 1888072 bytes

```

Text size 1565024 characters

```
Fast Replace: 0.237349 sec / 0.255545 sec / 0.253437 sec

Str::replace: 0.698960 sec / 0.260386 sec / 0.160027 sec

Fast Replace Memory usage: 3151704 bytes Peak memory usage: 5387896 bytes

Str::replace Memory usage: 3155024 bytes Peak memory usage: 6201160 bytes

```

### Still interested? then let's continue...

[](#still-interested-then-lets-continue)

Official Documentation
----------------------

[](#official-documentation)

Step 1:

```
        composer require bytenetizen/fast-replace

```

Step 2:

```
        php artisan migrate

        php artisan replace:seed

```

### Config

[](#config)

```
    life_cache default 10080 minute

    use_cache default true

    is_debug default false

```

### add .env \*optional

[](#add-env-optional)

```
    REPLACE_CACHE_LIFE=1
    REPLACE_USE_CACHE=false
    REPLACE_IS_DEBUG=false

```

### use Fast Replace

[](#use-fast-replace)

```
    use Bytenetizen\FastReplace\Facades\Replace;

```

notation: Use options can be combined!

#### To use the cache and still receive up-to-date information, use uni

[](#to-use-the-cache-and-still-receive-up-to-date-information-use-uni)

```
    $arr = [
        'uni'=>'',// user_id/ order_id ...
        'arrPlaceholder'=>['TEST'=>'Yap! Good test!','MY_NAME'=>'Promitey'],
    ];

```

option: 1 pass parameters immediately

```
    $arr = [
        'arrPlaceholder'=>['TEST'=>'Yap! Good test!','MY_NAME'=>'Promitey'],
    ];

    $startText = '{{TEST}} Lorem ipsum dolor sit amet, my name {{MY_NAME}}, consectetur adipiscing elit';

    $finishText = Replace::transform($startText,$arr);

    echo $finishText;

    "Yap! Good test! Lorem ipsum dolor sit amet, my name Promitey, consectetur adipiscing elit";

```

option: 2 use classes

```
    $startText = '{{TEST}}, {{NOW_TIME}} Lorem ipsum dolor sit amet, my name {{MY_NAME}}, consectetur adipiscing elit';

    $finishText = Replace::transform($startText);

    echo $finishText;

    "Hello world! PieceTest!, Wednesday 15th of November 2023 05:51:27 PM Lorem ipsum dolor sit amet, my name , consectetur adipiscing elit"

```

create new class

```
    php artisan make:placeholder PieceMyNew

```

app/Services/PieceMutators/PieceMyNew.php

insert DB new placeholder

```
    INSERT INTO `placeholders`(`piece`, `doer`, `admin_id`, `comments`) VALUES ('MY_NEW','App\Services\PieceMutators\PieceMyNew','1','my first Piece')

```

next:

```
    $startText = '{{MY_NEW}}!!! {{TEST}}, {{NOW_TIME}} Lorem ipsum dolor sit amet, my name {{MY_NAME}}, consectetur adipiscing elit';

    $finishText = Replace::transform($startText);

    echo $finishText;

    "PieceMyNew!! Hello world! PieceTest!, Wednesday 15th of November 2023 06:52:34 PM Lorem ipsum dolor sit amet, my name , consectetur adipiscing elit"

```

class

```
    use Bytenetizen\FastReplace\PieceMutators\Piece;

    class PieceMyNew extends Piece
    {
        public function getValue(): string
        {

            $this->placeholder; //The object itself is accessible Bytenetizen\ValueSwapper\Models\Placeholder
            $this->settings; //an array ($arr) is available with settings passed to $finishText = SwapperText::transform($startText,$arr);

            //for example, you can pass the user id and then do manipulations with the user object

                $userId = $this->settings['user_id']??null;
                $user = User::find($userId);

            return $user->name??'';
        }
    }

```

use classes

```
    $startText = '{{MY_NEW}}!!! {{TEST}}, {{NOW_TIME}} Lorem ipsum dolor sit amet, my name {{MY_NAME}}, consectetur adipiscing elit';

    $finishText = Replace::transform($startText);

    echo $finishText;

```

debug:

```
    $arr = [
        'arrPlaceholder'=>['TEST'=>'Yap! Good test!','MY_NOT_NAME'=>'Promitey'],
    ];

    $startText = '{{TEST_NOT_DATA}} Lorem ipsum dolor sit amet, my name {{MY_NAME}}, consectetur adipiscing elit';

    $finishText = Replace::transform($startText,$arr);

    echo $finishText;

    "!_EMPTY_{{TEST_NOT_DATA}}_! Lorem ipsum dolor sit amet, my name !_EMPTY_{{MY_NAME}}_!, consectetur adipiscing elit"

```

clean Placeholder

if placeholders are not needed, you can remove them

```
    $startText = '{{TEST_NOT_DATA}} Lorem ipsum dolor sit amet, my name {{MY_NAME}}, consectetur adipiscing elit';

    $arrDel = ['TEST_NOT_DATA','MY_NAME'];

    $cleanText = Replace::cleanPlaceholder($startText,$arrDel);

    echo $cleanText;

    "Lorem ipsum dolor sit amet, my name , consectetur adipiscing elit'

```

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

[](#contributing)

Thank you for considering contributing to Fast Replace!

License
-------

[](#license)

Laravel Tinker is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

902d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c2d01c3d67b5e326ee427ae406a4d13268de71cea58b1d9e508dfa195b986d2?d=identicon)[bytenetizen](/maintainers/bytenetizen)

---

Tags

laravelplaceholderreplacebytenetizenpieceTransform TextFast Replace

### Embed Badge

![Health badge](/badges/bytenetizen-fast-replace/health.svg)

```
[![Health](https://phpackages.com/badges/bytenetizen-fast-replace/health.svg)](https://phpackages.com/packages/bytenetizen-fast-replace)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

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